Hi,
I need to restore the expanded state of a RadTreeList after a redirect. I am storing the expanded items in Session before the redirect. However, server-side expansion only expands the root, not the child items.
Can someone share a JavaScript example or approach to fully expand all previously expanded nodes after a redirect using the stored session data? Or maybe provide a better example on Server Side
Thanks!
Hi,
I need to restore the expanded state of a RadTreeList after a redirect. I am storing the expanded items in Session before the redirect. However, server-side expansion only expands the root, not the child items.
Can someone share a JavaScript example or approach to fully expand all previously expanded nodes by the user after a redirect using the stored session data?
If your approach works in Server Side, I will use it on my solution
Thanks team!
This is an example using server side, but it expands only the first root element (not sure why)
Good morning! I would like to know if it is possible to save the state of the radtreelist with the nodes that were opened or closed and this way when the user reloads the screen it will be displayed the way it was before?
Radtreelist asp.net c#
Hi,
I'm trying to use the Treelist for a data source with the following definition
public class MyGridItem
{
public string ID { get; set; }
public string Name { get; set; }
public string ParentID { get; set; }
public bool IsIncluded { get; set; }
public bool IsExcluded { get; set; }
}
In markup I've got
<telerik:RadTreeList ID="RadTreeMarkers" runat="server" ParentDataKeyNames="ParentID" DataKeyNames="ID" AutoGenerateColumns="false"
OnNeedDataSource="RadTreeMarkers_NeedDataSource" AllowMultiItemEdit="true" ExpandCollapseMode="Client" EditMode="InPlace"
AllowPaging="false" AllowSorting="false" OnItemDataBound="RadTreeMarkers_ItemDataBound">
<Columns>
<telerik:TreeListBoundColumn DataField="ID" UniqueName="ID" Visible="false" ForceExtractValue="Always"></telerik:TreeListBoundColumn>
<telerik:TreeListBoundColumn DataField="ParentID" UniqueName="ParentID" Visible="false"></telerik:TreeListBoundColumn>
<telerik:TreeListBoundColumn DataField="Name" UniqueName="Name" HeaderText="Mark" ReadOnly="true"></telerik:TreeListBoundColumn>
<telerik:TreeListCheckBoxColumn DataField="IsIncluded" UniqueName="IsIncluded" HeaderText="Included" ForceExtractValue="Always"></telerik:TreeListCheckBoxColumn>
<telerik:TreeListCheckBoxColumn DataField="IsExcluded" UniqueName="IsExcluded" HeaderText="Excluded" ForceExtractValue="Always"></telerik:TreeListCheckBoxColumn>
</Columns>
</telerik:RadTreeList>
protected void RadTreeMarkers_NeedDataSource(object sender, TreeListNeedDataSourceEventArgs e)
{
var treeData = MyFacade.GetTreeData();
var treeDataGridItems = treeData.Select(m => new GridItem
{
ID = m.ID.ToString(),
Name = m.Name,
ParentID = m.ParentID.HasValue ? m.ParentID.Value.ToString() : string.Empty,
IsIncluded = m.IsIncluded.HasValue && m.IsIncluded == true,
IsExcluded = m.IsIncluded.HasValue && m.IsIncluded == false
}
).ToList();
RadTreeMarkers.DataSource = treeDataGridItems;
}
protected void RadTreeMarkers_ItemDataBound(object sender, TreeListItemDataBoundEventArgs e)
{
if (e.Item is TreeListDataItem item)
{
item.Edit = true;
}
}
The intention is for (only) the two checkboxes to be always editable in the client.
However, when rendered in the client the root items are editable but none of the child items is editable.
What am I doing wrong?


Hello,
I am attempting to integrate the drag/drop feature into a RadTreeList. The dragging is enabled and seems to work great but when an item is dropped it attempts a postback but does not change position. I assume this is because I need to manually assign it a value in comparison to a parent item. Does anyone have any experience or examples they could provide to display this functionality better? The most I have found online was this brief article:
https://docs.telerik.com/devtools/aspnet-ajax/controls/treelist/items/items-drag-and-drop
My code:
<telerik:RadTreeList ID="treeViewGrid" runat="server" DataKeyNames="ModuleId" CommandItemDisplay="Top" ParentDataKeyNames="ParentId" AutoGenerateColumns="false" EnableDragAndDrop="true">
<ClientSettings AllowItemsDragDrop="true">
<Selecting AllowItemSelection="True" />
</ClientSettings>
<Columns>
....
</columns>
....
Database:
moduleid
1
displayorder
1
moduletype
1
parentid
0
displayorder
2
moduletype
1
parentid
0
moduleid
2
My guess would be that there is a OnDropItem that runs server side where I can assign a new display order based on the previous order. Any help on this is appreciated! Thanks!
Once we add a selection column to the radtreelist, it left aligns the next column. However we need the 2nd column to align with the checkbox, is OK for all other columns to align. Thus for your demo page, the behavior we need is the Bound Column to have "Appetizers" immediately after the check so it appears as a label for the checkbox. How would I achieve this?
In Brief
The OnItemCommand ExpandCollapse event command doesn't fire when ClientSettings.AllowPostBackOnItemClick="true"
Detail
I am using a TreeList to display a company hierarchy. It is defined as follows.
<telerik:RadTreeList ID="lstCompanyTree" runat="server" PageSize="12" AllowLoadOnDemand="false" AllowPaging="true" Width="300px" OnNeedDataSource="lstCompanyTree_NeedDataSource" OnItemCommand="lstCompanyTree_ItemCommand" OnDataBound="lstCompanyTree_DataBound" OnItemDataBound="lstCompanyTree_ItemDataBound" OnPageIndexChanged="lstCompanyTree_PageIndexChanged" OnPreRender="lstCompanyTree_PreRender" AutoGenerateColumns="false" AllowSorting="false" CssClass="CompanyListTree" ShowTreeLines="true" ExpandCollapseMode="Server" DataKeyNames="CompanyID" ParentDataKeyNames="ParentCompanyID" ClientDataKeyNames="CompanyID,ObjectID" > <ClientSettings AllowPostBackOnItemClick="true" > <Selecting AllowItemSelection="true" /> </ClientSettings> <AlternatingItemStyle BackColor="Transparent" /> <ItemStyle BackColor="Transparent" /> <Columns> <telerik:TreeListTemplateColumn > <ItemTemplate> <div class="CompanyListItem"> <div class="layoutRow" <%# Eval("Style") %>> <div class="layoutCell dataCellMin200"><strong><%# Eval("Name") %></strong></div> </div> <div class="layoutRow"> <div class="layoutCell dataCellMin200"><%# Eval("SubHeading")%></div> </div> </div> </ItemTemplate> </telerik:TreeListTemplateColumn> </Columns> </telerik:RadTreeList>
I am trying to implement code when the Expand collapse button is clicked, and load the details of the company when an item is selected.
The problem is in the OnItemCommand event.
The ItemClick event command is overriding the ExpandCollapse command. If you disable AllowPostBackOnItemClick, then you get the ExpandCollapse command as expected.
that is, in this code block
protected void lstCompanyTree_ItemCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e){..}
e.CommandName is always "ItemClick" when AllowPostBackOnItemClick is true.
if you disable AllowPostBackOnItemClick , then e.CommandName = "ExpandCollapse" when you click the ExpandCollapse button. I haven't been able to test the value when the item is clicked as the postback is disabled, but one would assume e.CommandName = "ItemClick" in this case.

<telerik:RadButton ID="btnInsert" runat="server" Text="Insert" Width="75px" CommandName ="PerformInsert" Visible ="<%#DataItem is Telerik.Web.UI.TreeListInsertionObject %>" onclick="btnInsert_Click"> <Icon PrimaryIconCssClass ="rbSave" /> </telerik:RadButton> <telerik:RadButton ID="btnSave" runat="server" Text="Save" Width="75px" CommandName ="Update" Visible ="<%#!(DataItem is Telerik.Web.UI.TreeListInsertionObject) %>" onclick="btnSave_Click"> <Icon PrimaryIconCssClass ="rbSave" /> </telerik:RadButton> <telerik:RadButton ID="btnCancel" runat="server" Text="Cancel" Width="75px" CommandName ="Cancel" CausesValidation="False"> <Icon PrimaryIconCssClass ="rbCancel" /></telerik:RadButton>