This is a migrated thread and some comments may be shown as answers.

Wrong item returned when group collapsed

3 Answers 33 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 08 Apr 2009, 12:19 PM
Hello

I've an issue with a grid that is grouped by a column and has at least one group collapsed. In client side code, I'm handling the RowContextMenu event. There I use eventArgs.get_itemIndexHierarchical() to get the index of the row that was right clicked. This is returning the index in a way that considers the hidden rows that belong to the collapsed group(s). For example when the grid has four rows but the first three rows belong to a collapsed group and I right click the fourth row (which is the only one being displayed) eventArgs.get_itemIndexHierarchical() returns 3 which is what I'd expect.
But then I use this index to get the actual clicked DataItem using masterTableView.get_dataItems()[indexJustReturned]. But this does not return the correct item because the hidden items are not considered here. Instead nothing is returned because there is no item at position 3 when the hidden items aren't considered.

I'm not sure if this is a bug or if I'm misunderstanding anything. I've created a workaround using a for-loop that loops masterTableView.get_dataItems(). In that loop I compare the current item's _itemIndexHierarchical value with the indexJustReturned, which I don't think is nice because I'm accessing the _itemIndexHierarchical.

So how to get the item from masterTableView.get_dataItems() when there are collapsed groups?

Thank you

Christian

3 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 13 Apr 2009, 02:30 PM
Hello Christian,

The item's hierarchical index is set when the grid is bound. Hence only the expanded groups contain rows. In other words, only the rows which belong to the expanded groups are rendered. If the GroupLoadMode is set to "server", and the groups are collapsed, it is expected the collection returned from get_dataItems() method to contain only rendered rows.

To get the data item with masterTableView.get_dataItems()[indexJustReturned] method, you need to set the GroupLoadMode to "Client". Thus all rows are rendered even if they are not shown when the group is collapsed. In this case the get_dataItems()[indexJustReturned] item will be the correct one.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 16 Apr 2009, 08:58 AM
Hello Georgi

Thank you for your reply!

In my grid the groups are always expanded when the grid is bound at the server side. So it's always the user who is collapsing a group which occurs only on the client side. So I suppose the collapsed groups still contain the rows they contained when the grid was bound. 

So I'm wondering why setting GroupLoadMode to "Client" will help in my case.

Best regards

Christian
0
Georgi Krustev
Telerik team
answered on 16 Apr 2009, 02:15 PM
Hi Christian,

When GroupLoadMode is set to "server" all closed groups do not contain their rows anymore. In other words, when you collapse the group all rows which belongs to it will not be persisted (will not be rendered).

Please review this online help article for more details.

Best regards,
Georgi Krustev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Christian
Top achievements
Rank 1
Share this question
or