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

TreeListSelectColumn allow item selection question

2 Answers 148 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 24 Feb 2016, 03:52 PM

I'm running the latest build and using server side selection with a TreeListSelectColumn. Markup is below. The server side event SelectedIndexChanged is firing properly and I am using AJAX to update additional controls from the SQL database. Currently the user has to click on the checkbox (i.e. select column) to fire the selected index event and select the item in the tree. I would like to allow the user to click any column in the list to select the item (i.e. checkbox or item text) and fire the selected index event and subsequently the item to be selected.

Is this possible through a setting? I can't seem to find it. Or is there some custom code I need to add to implement this functionality. Thanks..

<telerik:RadTreeList ID="radtreeCustomer" runat="server" AutoGenerateColumns="false" AllowMultiItemSelection="false" GridLines="None">
   <Columns>
      <telerik:TreeListSelectColumn Display="true" UniqueName="Checked" HeaderStyle-Width="30px"></telerik:TreeListSelectColumn>
      <telerik:TreeListBoundColumn Display="false" UniqueName="Organization_Id" DataField="Organization_Id"></telerik:TreeListBoundColumn>
      <telerik:TreeListBoundColumn Display="false" UniqueName="Parent_Organization_Id" DataField="Parent_Organization_Id"></telerik:TreeListBoundColumn>
      <telerik:TreeListBoundColumn Display="true" UniqueName="Business_Name" DataField="Business_Name"></telerik:TreeListBoundColumn>
   </Columns>
</telerik:RadTreeList>

2 Answers, 1 is accepted

Sort by
0
Accepted
Viktor Tachev
Telerik team
answered on 26 Feb 2016, 02:21 PM
Hi Steve,

In case you would like to keep using server-side selection and implement the described functionality you need to do the following:

  • set the ClientSettings-AllowPostBackOnItemClick property or the RadTreeList to true
  • handle the OnItemCommand event

In the event handler you can check if it was initiated by a click and then toggle the selection for the current item:

protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
{
    if (e.CommandName == "ItemClick")
    {
        TreeListDataItem clickedItem = e.Item as TreeListDataItem;
 
        clickedItem.Selected = !clickedItem.Selected;
    }
}


Regards,
Viktor Tachev
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Steve
Top achievements
Rank 1
answered on 26 Feb 2016, 03:08 PM
Thank you that did it. I'm using the clickedItem.Cells array to determine the key value that was selected.
Tags
TreeList
Asked by
Steve
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
Steve
Top achievements
Rank 1
Share this question
or