Set all RadTreeList items to edit mode

1.1k views Asked by At

I have been working with Telerik RadGrids and I haven't had any problem setting all items to edit mode when I'm populating the grid.

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem)
    {
        e.Item.Edit = true;
    }
}

Now I'm working with a Telerik RadTreeList and I would like to do something similar. Is it any possible way to do this? As far as I have been searching, I haven't found any possible solution for this.

2

There are 2 answers

0
razp26 On BEST ANSWER

The solution goes as follows:

protected void RadTreeList1_PreRender(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        foreach (TreeListDataItem item in RadTreeList1.Items)
        {
            if (item is TreeListDataItem)
            {
                item.Edit = true;
            }
        }
        RadTreeList1.Rebind();
    }
}

The (!IsPostBack) condition would depend on if the TreeListDataItem get's populated at Page_Load.

4
Abhinav On

Did you check at http://www.telerik.com/help/aspnet-ajax/treelist-server-side-basics.html?

RadTreeList has an ItemCreated event as well.

Can you try?

protected void RadTreeList1_ItemCreated(object sender, TreeListItemCreatedEventArgs e)
{
    if (e.Item is TreeListDataItem)
    {
        TreeListDataItem item = e.Item as TreeListDataItem;
        item.Edit = true;
    }
}