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

Event for Server-Side Select All?

1 Answer 94 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
John Horton
Top achievements
Rank 1
John Horton asked on 01 Apr 2011, 09:54 PM
I have a TreeList that allows multiple row selection (server-side) and has a TreeListSelectColumn.  This configuration also creates a checkbox in the header that allows all rows to be selected/deselected.  When an individual row is selected the expected ItemCommand event is triggered on the server-side.  However, when the select-all checkbox in the header is checked and all rows are selected, the subsequent postback does not generate ItemCommand events.  Is there a particular event for this select-all postback? Any recommendations for capturing these selection changes?

<telerik:RadTreeList ID="OrganizationTreeList"
                     runat="server"
                     AllowPaging="True"
                     AllowSorting="True"
                     AllowMultiItemSelection="True"
                     AutoGenerateColumns="false"
                     DataKeyNames="ID"
                     ParentDataKeyNames="ParentID"
                     GridLines="Vertical"
                     OnNeedDataSource="OrganizationTreeList_OnNeedData"
                     OnItemDataBound="OrganizationTreeList_OnItemDataBound"
                     OnItemCommand="OrganizationTreeList_ItemCommand">
    <NoRecordsTemplate>
        There are no organizations to display.
    </NoRecordsTemplate>
    <Columns>
        <telerik:TreeListSelectColumn UniqueName="SelectColumn" HeaderStyle-Width="5%"  />
        <telerik:TreeListBoundColumn DataField="ID" 
                                     HeaderText="ID"
                                     UniqueName="ID"
                                     HeaderStyle-Width="80px"
                                     HeaderStyle-HorizontalAlign="Center"
                                     ItemStyle-HorizontalAlign="Center" />
        <telerik:TreeListCheckBoxColumn DataField="IsActive"
                                        HeaderText="Active"
                                        UniqueName="IsActive"
                                        HeaderStyle-Width="55px"
                                        HeaderStyle-HorizontalAlign="Center"
                                        ItemStyle-HorizontalAlign="Center" />
        <telerik:TreeListBoundColumn DataField="Name"
                                     HeaderText="Name"
                                     UniqueName="Name"
                                     HeaderStyle-Width="68%" />
    </Columns>
    <PagerStyle Mode="NextPrevAndNumeric"  />
</telerik:RadTreeList>   

1 Answer, 1 is accepted

Sort by
0
Accepted
Marin
Telerik team
answered on 07 Apr 2011, 09:55 AM
Hello John,

We confirm that the ItemCommand event does not fire in this case. The issue has been forwarded to our development team for further investigation.
A temporary workaround would be to attach a client function to the onclick event of the checkbox in the header that fires a command and raises postback on the server. Here is a sample code:

protected void Page_PreRender(object sender, EventArgs e)
       {
           TreeListItem headerItem = RadTreeList1.GetItems(new TreeListItemType[] { TreeListItemType.HeaderItem })[0];
           (headerItem.Cells[0].Controls[0] as CheckBox).Attributes["onclick"] = "raiseSelect();";
       }

function raiseSelect()
            {
                var treelist = $find("<%= RadTreeList1.ClientID %>");
                treelist.fireCommand("Select","0");
                //note that this will simulate raising an item command event as if the first data item has been selected
            }

Feel free to contact us again if you have any other questions.


Greetings,
Marin
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
TreeList
Asked by
John Horton
Top achievements
Rank 1
Answers by
Marin
Telerik team
Share this question
or