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

get_itemIndexHierarchical returns incorrect value when collapsed groups over

1 Answer 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
øystein daaland
Top achievements
Rank 1
øystein daaland asked on 03 Aug 2010, 08:57 PM
Seems that get_itemIndexHierarchical returns incorrect value when there are collapsed groups over the selected item. 

I have an ajaxified radgrid with radcontextmenu that calls a function. In this function eventargs.get_itemIndexHierarchical is used to get the index. This is done according to your example with radgrid and radcontextmenu. Sender.get_masterTableView().get_dataItems()[index].get_element() is then called but returns null, which is not the wanted behaviour. Expand/collapse is done server-side and only the expanded items are transferred to the client as i can see. This is working when groups over the selected item are expanded.

Maybe there are other ways to get index of the selected item when using radcontextmenu and radgrid with expand/collapse server-side? 

Regards
daaland1972

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 06 Aug 2010, 02:11 PM
Hello daaland1972

Note that this online example is not intended to work when grouping is enabled. To use it in such scenarios you can follow one of the approaches bellow:

  • Remove the selection logic from the RowContextMenu event handler.
  • Modify the selection logic so that the correct item is selected. The drawback is that this approach would not work for hierarchical scenarios:

    function RowContextMenu(sender, eventArgs)
    {
    ...
     
       var index = eventArgs.get_itemIndexHierarchical();
       var masterTableView = sender.get_masterTableView();
       var rowId = masterTableView.get_id() + "__" + index;
       var items = masterTableView.get_dataItems();
       $find(rowId).set_selected(true);
                    //sender.get_masterTableView().selectItem(sender.get_masterTableView().get_dataItems()[index].get_element(), true);
     
    ...
    }

  • Use GroupLoadMode = "Client" for your GridTableView object.

I hope this helps.

Regards,
Martin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
øystein daaland
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or