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

Conditional Readonly for TreeList

2 Answers 81 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Mohith
Top achievements
Rank 1
Mohith asked on 04 Jan 2013, 11:44 AM
Hi,

I want to make few levels of a treelist readonly. For example, say the tree has levels 0,1,2,3 etc. I want to make only levels 1 and 2 to be readonly and rest of the levels to be edited. can you please help me with this requirement? I tried by marking ReadOnly = "true" for the bound column but that makes the entire column readonly not only 1 or 2 in the hierarchy. Please help!

Thanks,
Mohith

2 Answers, 1 is accepted

Sort by
0
Accepted
Angel Petrov
Telerik team
answered on 09 Jan 2013, 09:54 AM
Hello Mohith,

The easiest way to implement this functionality is to intercept the OnItemCommand event. If the CommandName is "Edit" you can check the NestedLevel index of the TreeListDataItem and if it is equal to 1 or 2 cancel the event. A demonstration of this is shown in this code snippet:
protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
    {
        if (e.CommandName == "Edit")
        {
            TreeListDataItem item = e.Item as TreeListDataItem;
            int index=item.HierarchyIndex.NestedLevel;
            if (index == 1 || index == 2) e.Canceled=true;
        }
    }

All the best,
Angel Petrov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Mohith
Top achievements
Rank 1
answered on 10 Jan 2013, 09:38 AM
That worked..Thanks!
Tags
TreeList
Asked by
Mohith
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Mohith
Top achievements
Rank 1
Share this question
or