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

Get the row index via a treeListCommandEventArgs

2 Answers 226 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Jul 2011, 10:02 PM
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 Answers, 1 is accepted

Sort by
0
Accepted
Veli
Telerik team
answered on 11 Jul 2011, 05:17 PM
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!

0
David
Top achievements
Rank 1
answered on 11 Jul 2011, 09:51 PM
Thank you, it works great
Tags
TreeList
Asked by
David
Top achievements
Rank 1
Answers by
Veli
Telerik team
David
Top achievements
Rank 1
Share this question
or