In Brief
The OnItemCommand ExpandCollapse event command doesn't fire when ClientSettings.AllowPostBackOnItemClick="true"
Detail
I am using a TreeList to display a company hierarchy. It is defined as follows.
<
telerik:RadTreeList
ID
=
"lstCompanyTree"
runat
=
"server"
PageSize
=
"12"
AllowLoadOnDemand
=
"false"
AllowPaging
=
"true"
Width
=
"300px"
OnNeedDataSource
=
"lstCompanyTree_NeedDataSource"
OnItemCommand
=
"lstCompanyTree_ItemCommand"
OnDataBound
=
"lstCompanyTree_DataBound"
OnItemDataBound
=
"lstCompanyTree_ItemDataBound"
OnPageIndexChanged
=
"lstCompanyTree_PageIndexChanged"
OnPreRender
=
"lstCompanyTree_PreRender"
AutoGenerateColumns
=
"false"
AllowSorting
=
"false"
CssClass
=
"CompanyListTree"
ShowTreeLines
=
"true"
ExpandCollapseMode
=
"Server"
DataKeyNames
=
"CompanyID"
ParentDataKeyNames
=
"ParentCompanyID"
ClientDataKeyNames
=
"CompanyID,ObjectID"
>
<
ClientSettings
AllowPostBackOnItemClick
=
"true"
>
<
Selecting
AllowItemSelection
=
"true"
/>
</
ClientSettings
>
<
AlternatingItemStyle
BackColor
=
"Transparent"
/>
<
ItemStyle
BackColor
=
"Transparent"
/>
<
Columns
>
<
telerik:TreeListTemplateColumn
>
<
ItemTemplate
>
<
div
class
=
"CompanyListItem"
>
<
div
class
=
"layoutRow"
<%# Eval("Style") %>>
<
div
class
=
"layoutCell dataCellMin200"
><
strong
><%# Eval("Name") %></
strong
></
div
>
</
div
>
<
div
class
=
"layoutRow"
>
<
div
class
=
"layoutCell dataCellMin200"
><%# Eval("SubHeading")%></
div
>
</
div
>
</
div
>
</
ItemTemplate
>
</
telerik:TreeListTemplateColumn
>
</
Columns
>
</
telerik:RadTreeList
>
I am trying to implement code when the Expand collapse button is clicked, and load the details of the company when an item is selected.
The problem is in the OnItemCommand event.
The ItemClick event command is overriding the ExpandCollapse command. If you disable AllowPostBackOnItemClick, then you get the ExpandCollapse command as expected.
that is, in this code block
protected
void
lstCompanyTree_ItemCommand(
object
sender, Telerik.Web.UI.TreeListCommandEventArgs e)
{
..
}
e.CommandName is always "ItemClick" when AllowPostBackOnItemClick is true.
if you disable AllowPostBackOnItemClick , then e.CommandName = "ExpandCollapse" when you click the ExpandCollapse button. I haven't been able to test the value when the item is clicked as the postback is disabled, but one would assume e.CommandName = "ItemClick" in this case.