Wrong item returned when group collapsed

4 posts, 0 answers
  1. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 08 Apr 2009 Link to this post

    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
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 13 Apr 2009 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Christian
    Christian avatar
    22 posts
    Member since:
    Nov 2008

    Posted 16 Apr 2009 Link to this post

    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
  5. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 16 Apr 2009 Link to this post

    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.
Back to Top