This is a migrated thread and some comments may be shown as answers.

ExpandCollapse Command Doesnt Fire

1 Answer 83 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 2
Jason asked on 13 Aug 2020, 05:01 PM

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.

 

 

1 Answer, 1 is accepted

Sort by
0
Doncho
Telerik team
answered on 18 Aug 2020, 02:08 PM

Hi Jason,

Thank you for the information provided!

Still, I am afraid I was not able to reproduce the described behavior.

I have tested a similar setup to the one you have shared, and it works as expected, see http://somup.com/cYjFIm6Gnf

In order to help with troubleshooting I will need a reproduction of the problematic behavior. Could you please share the steps to replicate the problem? It would be very helpful if you provide us a runnable sample where we can experience the issue ourselves.

I have also attached a sample project for you to test. To be able to run in it, you need to copy the Telerik.Web.UI.dll and Telerik.Web.UI.xml in the bin folder. It would also be a great help if you modify the sample project so that it reproduces the error and send it back to us for troubleshooting.

Looking forward to hearing from you!

Kind regards,
Doncho
Progress Telerik

Tags
TreeList
Asked by
Jason
Top achievements
Rank 2
Answers by
Doncho
Telerik team
Share this question
or