Customer Renderer with SimpleGroupsModel

asked 2012-10-26 19:11:31 +0800

ansancle gravatar image ansancle
317 9

I apologize if this has been covered - i could not find it anywhere. All the examples given that use SimpleGroupsModel and use a Grid provide Strings as the data - meaning you don't need a custom renderer. Simply setting the Model into the Grid does the trick.

I need to use a custom RowRenderer for both the Headers (Groups) and the data within each Group. When I use a RowRenderer the Render method :

public void render(Row row, Object obj, int index) throws Exception

gets called the same regardless if it's the header or the data within each group - I have no way of knowing what the data being passed in is - a header of just part of a group. I am initializing the SimpleGroupsModel with an array of collections - that is the data within each group, and a collection that is the groups themselves.

ArrayList<Collection<Integer>> arrayOfCollections = new ArrayList<Collection<Integer>>();
ArrayList groupHeaderList = new ArrayList<Integer>();
// Then I load these with the correct data.....
// Then I pass to the grid

		GroupsModel model = new SimpleGroupsModel(arrayOfCollections,groupHeaderList);

My RowRenderer does get called, but I can't figure out how to know when it's a group that should be rendererd and when it's not withing comparing it against my data - which is slow.
Does anyone have some example code of a Grouped Grid using a Custom Row Renderer?


delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2012-10-29 08:29:52 +0800

vincentjian gravatar image vincentjian
2245 6

Hi Andy,

It seems using GroupsModelArray is better than SimpleGroupModel in your case
Please reference the document here.

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2012-10-26 19:11:31 +0800

Seen: 71 times

Last updated: Oct 29 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More