Get the row index via a treeListCommandEventArgs

3 posts, 1 answers
  1. David
    David avatar
    81 posts
    Member since:
    May 2011

    Posted 07 Jul 2011 Link to this post

    Hi,

    I was wondering how can I get the index of row in the UpdateCommand events of a TreeList. In a RadGrid, it would be like this :

    Guid uniqueIdentifer= Guid.Parse((RadGrid1.Items[e.Item.ItemIndex] as GridDataItem)["UniqueIdentifier"].Text);

    But if doesn't work with a treeList. In fact, the proprety e.Item.ItemIndex doesn't seem to exist. So, I look around to found something, but I had no luck. So, may someone tell me how to retrieve the index of the selected row via a updateCommand.

    Thank you
  2. Answer
    Veli
    Admin
    Veli avatar
    2002 posts

    Posted 11 Jul 2011 Link to this post

    Hello David,

    This depends on the EditMode you are using. If using InPlace edit mode, the e.Item property in the event handler refers to the TreeListDataItem that is in edit mode. In this case you can cast e.Item to TreeListDataItem and get its DisplayIndex:

    ((TreeListDataItem)e.Item).DisplayIndex

    In fact, if you need to access the data item with this approach, it is already there - e.Item is your data item.

    The other approach is if you are using EditForms or PopUp edit mode. In this case, your edited item is of type TreeListEditFormItem and its .ParentItem property gives you the respective data item and its DisplayIndex:

    ((TreeListEditFormItem)e.Item).ParentItem

    Greetings,
    Veli
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. David
    David avatar
    81 posts
    Member since:
    May 2011

    Posted 11 Jul 2011 Link to this post

    Thank you, it works great
Back to Top