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?
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?
6 Answers, 1 is accepted
0
Kushal
Top achievements
Rank 1
answered on 27 Sep 2011, 12:40 PM
Resending...
any help is greatly appriciated.
any help is greatly appriciated.
0
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
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
0
Kushal
Top achievements
Rank 1
answered on 05 Oct 2011, 12:54 PM
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?
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?
0
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:
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.
For more information on accessing controls in RadTreeList, see this article:
Accessing Cells and Items
All the best,
Tsvetina
the Telerik team
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
0
Kushal
Top achievements
Rank 1
answered on 07 Oct 2011, 07:11 AM
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);
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);
0
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
Best wishes,
Tsvetina
the Telerik team
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