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

Itemindex in a Collapse/Expand Grid

7 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Christian
Top achievements
Rank 1
Christian asked on 10 Aug 2009, 07:25 AM

Dear Comunity,

I have the following problem.

I have a grid with 10 Items grouped in 2 a 5 items for example.

If all groups are expand I can access all items with the index of itself. If I collaps one group and try to access a item with its index I get a error because the grid has only 5 items, but the index of the item to access has the index 8. I think this isn't a problem but how can get the correct index for each item in grid if a group is expand/collaps.

To get the index of the item to edit I'm using the RowDblClick event of teh grid and get the eventArgs.get_itemIndexHierarchical();

 

 

Is there a better solution to get it and solve my problem.
Thanks in advace.

Christian

7 Answers, 1 is accepted

Sort by
0
Christian
Top achievements
Rank 1
answered on 11 Aug 2009, 07:40 AM
Hello again,

someone an idea how I can solve or workaround this problem?

Thanks again.
Christian
0
Shinu
Top achievements
Rank 2
answered on 11 Aug 2009, 09:35 AM
Hi Christian,

I am not sure what exactly is your requirement.  But to set the Grid row in edit mode on double clicking a row you may try the following code snippet. The below given code does not depend on whether the Grouped Grid is expanded or collapsed. But any ways you need to expand the Grouped row to get access to its child item.

ASPX:
 
  <ClientEvents OnRowDblClick="EditOnDoubleClick"  /> 

JS:
 
<script type="text/javascript"
 
    function EditOnDoubleClick(sender, eventArgs) 
    { 
      var masterTable = $find("<%= RadGrid1.ClientID %>").get_masterTableView(); 
      masterTable.editItem(masterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()].get_element()); 
    } 
  
</script> 


Thanks
Shinu.
0
Christian
Top achievements
Rank 1
answered on 12 Aug 2009, 04:38 PM
Hi Shinu

thanks for the replay.

Unfortunaly not. Becase the eventArgs.get_itemIndexHierarchical() returns a value thats currently out of range if the groups arroung are collapsed.(Most of all the first or last item in the expand group with a colapsed group before and a group after the expand group with the edit item)

So if I used your example with a collapsed group before and a collapsed group after the edit group the eventArgs.get_itemIndexHierarchical() gives me a wrong value. If I try than to get the datatiem with this value the functon returns undefines. On the otherside if alle gropups are expand evertyhing works fine.

Any idea for this problem?

Thanks
Christian
0
Christian
Top achievements
Rank 1
answered on 14 Aug 2009, 06:26 AM
Hello Support,

it would be really welcome if someone can help me out with my probelm.

Thanks.

Chrsitian
0
Christian
Top achievements
Rank 1
answered on 17 Aug 2009, 07:23 AM
Hello,

Unfortnunaly I can't found a solution for my probelme,

Please help me out!!

Thanks again

Christian
0
Accepted
Iana Tsolova
Telerik team
answered on 17 Aug 2009, 11:37 AM
Hi,

Could you try setting the GroupLoadMode property of the grid MasterTableView to Client and see if it makes any difference? In this case you might also set the AllowGroupExpandCollapse property in the grid ClientSettings to true.
If the issue persists, I suggest that you send us a runnable sample illustrating your scenario and the issue you are facing. Thus I could debug it in depth locally in order to find a resolution for you.

All the best,
Iana
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.
0
Christian
Top achievements
Rank 1
answered on 17 Aug 2009, 06:03 PM
Hi Lana,

what can I say only THANKS ALOT :-)

Thats the right hint to solve it. And if I know it its so easy. Everytime the same.

Again thanks alot. If I could I gave you 10.000 Telerik Points for this help ;-)

Have a nice time.

Chrsitian
Tags
Grid
Asked by
Christian
Top achievements
Rank 1
Answers by
Christian
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or