Hi All,
I want to remove the plus(Add) button from all the child nodes. How can i achieve it?
Thanks,
Amit Choudhary
I want to remove the plus(Add) button from all the child nodes. How can i achieve it?
Thanks,
Amit Choudhary
3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 19 Oct 2011, 11:33 AM
Hello Amit,
You can try the following CSS to remove Expand and Collapse buttons.
CSS:
Thanks,
Princy.
You can try the following CSS to remove Expand and Collapse buttons.
CSS:
<style type=
"text/css"
>
.RadTreeList_Default .rtlExpand
{
background-image
:
none
!important
;
}
.RadTreeList_Default .rtlCollapse
{
background-image
:
none
!important
;
}
</style>
Thanks,
Princy.
0
Amit
Top achievements
Rank 1
answered on 19 Oct 2011, 11:39 AM
Hi Princy,
I want to remove the Add button for all child nodes as shown in attached image.
Thanks,
Amit Choudhary
I want to remove the Add button for all child nodes as shown in attached image.
Thanks,
Amit Choudhary
0
Accepted
Hello Amit,
You can use the ItemDataBound event in RadTreeList to do that.
If you only have 2 levels of hierarchy and you want to remove the add new button from the child items, you can use the following snippet:
Alternatively, if you have more than 2 levels of hierarchy and want to hide the add button for leaf nodes only, you can take a different approach:
The second approach searches for the expand/collapse button in the data item. If none is found, the item is a "loaf node", meaning it does not have any child items and should have its add button hidden.
Veli
the Telerik team
You can use the ItemDataBound event in RadTreeList to do that.
If you only have 2 levels of hierarchy and you want to remove the add new button from the child items, you can use the following snippet:
protected
void
RadTreeList1_ItemDataBound(
object
sender, TreeListItemDataBoundEventArgs e)
{
if
(e.Item
is
TreeListDataItem)
{
var dataItem = (TreeListDataItem)e.Item;
if
(dataItem.HierarchyIndex.NestedLevel != 0)
{
//specify your edit column's UniqueName here
dataItem[
"EditCommandColumn"
].Controls[0].Visible =
false
;
}
}
}
Alternatively, if you have more than 2 levels of hierarchy and want to hide the add button for leaf nodes only, you can take a different approach:
protected
void
RadTreeList1_ItemDataBound(
object
sender, TreeListItemDataBoundEventArgs e)
{
if
(e.Item
is
TreeListDataItem)
{
var dataItem = (TreeListDataItem)e.Item;
bool
isLeaf =
true
;
//search for an expand/collapse button in the item
foreach
(TableCell cell
in
dataItem.Cells)
{
if
(cell.Controls.Count > 0 && cell.Controls[0].ID ==
"ExpandCollapseButton"
)
{
isLeaf =
false
;
break
;
}
}
if
(isLeaf)
{
dataItem[
"EditCommandColumn"
].Controls[0].Visible =
false
;
}
}
}
The second approach searches for the expand/collapse button in the data item. If none is found, the item is a "loaf node", meaning it does not have any child items and should have its add button hidden.
Veli
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