How to make child rows non-editable

7 posts, 0 answers
  1. Kushal
    Kushal avatar
    11 posts
    Member since:
    Sep 2011

    Posted 26 Sep 2011 Link to this post

    I have a requirement to edit the parent row but child rows should not be editable. when a value in the parent cell updated, the same cell in all the child rows should be updated with the same value.
    Please let me know how to make parent row editable but at the same time child rows should not be editable and how to udpate the values to child rows on modification of a parent row?
  2. Kushal
    Kushal avatar
    11 posts
    Member since:
    Sep 2011

    Posted 27 Sep 2011 Link to this post

    Resending...
    any help is greatly appriciated.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 28 Sep 2011 Link to this post

    Hello Kushal,

    You could use the ItemCreated event of the RadTreeList and based on the NestedLevel of the TreeListDataItem, to access the controls of the edit command column and switch their visibility. The NestedLevel is available through (e.Item as TreeListDataItem).HierarchyIndex.NestedLevel.

    As for updating the child rows data based on the currently updated parent row, you could loop through the parent's ChildItems collection, fire an Update command for each and change the value in question inside the UpdateCommand event.

    Greetings,
    Tsvetina
    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
  5. Kushal
    Kushal avatar
    2 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    Thanks Tsvetina.
    How do I access the controls of the edit command column and switch their visibility? Can you show me  an example of it.

    If I set the visibility of edit command cell to false, the row will have less number of cell and it will disturb the grid.
    actually I wanted to set properties : showcancel = false , showInsert=false .

    Can you give some example for it or point me to some article about it?
  6. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 05 Oct 2011 Link to this post

    Hi Kushal,

    These are properties of the whole column object and you cannot set them only for specific cells. That is why I suggested you the other approach.

    If you prefer to hide all buttons, you can use the following code:
    protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
    {
        if (e.CommandName == RadTreeList.EditCommandName)
        {
            (RadTreeList1.GetColumnSafe("EditColumn") as TreeListEditCommandColumn).ShowAddButton = false;
            (RadTreeList1.GetColumnSafe("EditColumn") as TreeListEditCommandColumn).ShowEditButton = false;
     
        }
    }

    If you want to hide specific ones, you can use FindControl in the specific cell (that I assume you have already accessed) to and use the following IDs to access the edit and insert button:
    InsertButton_EditColumn
    EditButton_EditColumn
    e.g.
    protected void RadTreeList1_PreRender(object sender, EventArgs e)
    {
        foreach (TreeListEditFormItem item in RadTreeList1.EditItems)
        {
            foreach (TreeListDataItem childItem in item.ParentItem.ChildItems)
            {
                childItem["EditColumn"].FindControl("InsertButton_EditColumn").Visible = false;
            }
        }
    }


    For more information on accessing controls in RadTreeList, see this article:
    Accessing Cells and Items

    All the best,
    Tsvetina
    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
  7. Kushal
    Kushal avatar
    2 posts
    Member since:
    Sep 2011

    Posted 07 Oct 2011 Link to this post

    Thank you Tsvetina for the response.

    I have a asp.net DropDownList in a TreeListTemplateColumn.
    In InsertCommand event how do you access dropdownlist's selected value.

    I tried the following code, but it table doesn't contain template column value. Is there any specific way to retrieve it.
                Hashtable table = new Hashtable();
                TreeListEditableItem item = e.Item as TreeListEditableItem;
                item.ExtractValues(table);
  8. Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 10 Oct 2011 Link to this post

    Hi Kushal,

    You could use the same code as when accessing insert values in a FormTemplate: get hold of the inserted item and then use the FindControl method to access the dropdown by ID:
    Inserting Values Using FormTemplate/UserControl
    protected void RadTreeList1_InsertCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
    {
        //Extracting the values from the form template edit form using the FindControl() method
        TreeListEditFormInsertItem insertedItem = e.Item as TreeListEditFormInsertItem;
        string title = (insertedItem.FindControl("TitleDdl") as DropDownList).SelectedValue;
        ....
    }


    Best wishes,
    Tsvetina
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017