Itemindex in a Collapse/Expand Grid

8 posts, 1 answers
  1. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 10 Aug 2009 Link to this post

    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

  2. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 11 Aug 2009 Link to this post

    Hello again,

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

    Thanks again.
    Christian
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2009 Link to this post

    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.
  5. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 12 Aug 2009 Link to this post

    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
  6. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 14 Aug 2009 Link to this post

    Hello Support,

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

    Thanks.

    Chrsitian
  7. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 17 Aug 2009 Link to this post

    Hello,

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

    Please help me out!!

    Thanks again

    Christian
  8. Answer
    Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 17 Aug 2009 Link to this post

    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.
  9. Christian Pardun
    Christian Pardun avatar
    112 posts
    Member since:
    May 2010

    Posted 17 Aug 2009 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017