I'm building a control that runs inside of the DetailsView of Rad TreeList.
My naming container is a TreeListDetailTemplateItem. From this context, I can't find an easy way to get access to the TreeListDataItem for this row (To get DisplayIndex). If it happens we are data-binding, I can do this hack:
I have the same limitation from within TreeList -> ItemCreated(). When trying to draw a Context menu for my DetailsView body, I run into an issue getting the DisplayIndex. Per this example: http://www.telerik.com/community/forums/aspnet-ajax/treelist/dose-the-tree-list-have-a-context-menu-funcationality.aspx#1428456
I had to hack around it using this code:
Anyone know some magical cast/path to jump from TreeListDetailTemplateItem to TreeListDataItem? Also, will these controls be implementing IDataItemContainer anytime soon?
My naming container is a TreeListDetailTemplateItem. From this context, I can't find an easy way to get access to the TreeListDataItem for this row (To get DisplayIndex). If it happens we are data-binding, I can do this hack:
var detaiItem = (this.NamingContainer as TreeListDetailTemplateItem); if (detailItem.DataItem != null) { //HACK: Cast to my business class, use the key value to find the appropriate treelistDataItem var itemId = (detailItem.DataItem as CheckListItem).CheckListItemID; treeListDataItem = RadTreeList1.Items.Where(i => (int) i.GetDataKeyValue("CheckListItemID") == itemId).SingleOrDefault(); var displayIndex = treeListDataItem.DisplayIndex ..... }I had to hack around it using this code:
protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e){ TreeListDataItem treeListDataItem = null; if (e.Item is TreeListDataItem ) { treeListDataItem = (TreeListDataItem)e.Item; treeListDataItem.Attributes["oncontextmenu"] = "ShowContextMenu(" + treeListDataItem.DisplayIndex + ", event);"; } else if (e.Item is TreeListDetailTemplateItem) { // We need the TreeListDataDataItem so we can use it's Display Index var detailItem = (e.Item as TreeListDetailTemplateItem); if (detailItem.DataItem != null) { var itemId = (detailItem.DataItem as CheckListItem).CheckListItemID; treeListDataItem = RadTreeList1.Items.Where(i => (int) i.GetDataKeyValue("CheckListItemID") == itemId).SingleOrDefault(); detailItem.Attributes["oncontextmenu"] = "ShowContextMenu(" + treeListDataItem.DisplayIndex + ", event);"; } } }Anyone know some magical cast/path to jump from TreeListDetailTemplateItem to TreeListDataItem? Also, will these controls be implementing IDataItemContainer anytime soon?