Conditional Readonly for TreeList

3 posts, 1 answers
  1. Mohith
    Mohith avatar
    8 posts
    Member since:
    Apr 2011

    Posted 04 Jan 2013 Link to this post

    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. Answer
    Angel Petrov
    Admin
    Angel Petrov avatar
    1006 posts

    Posted 09 Jan 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Mohith
    Mohith avatar
    8 posts
    Member since:
    Apr 2011

    Posted 10 Jan 2013 Link to this post

    That worked..Thanks!
Back to Top