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

DropDownList in TreeListTemplateColumn loses selected value on Expand/Collapse

3 Answers 88 Views
TreeList
This is a migrated thread and some comments may be shown as answers.
Lynne
Top achievements
Rank 1
Lynne asked on 03 Apr 2014, 04:38 PM
I have a simple RadTreeList containing a BoundColumn and a TemplateColumn of type dropdownlist. I've populated the DDL dynamically for each row. The treelist displays perfectly, but when I select a value from the dropdown list on one or more rows, then collapse/expand the tree node, the values selected in the DDLs are lost. I think it is probably due to data binding.   

The intent is for the user to a select a value from the DDL for each row in the TreeList then save the values to the database once they are finished.  I want them to be able to expand/collapse tree nodes during this process without losing the values.  I've searched through the forum and read much of the documentation online, but I would appreciate some insight into the best approach for solving this issue.  Thanks in advance. 
 
 
<telerik:RadTreeList ID="RadTreeList1" runat="server" 
    AutoGenerateColumns="False" 
    DataKeyNames="Node" ParentDataKeyNames="ParentNode" OnItemDataBound="RadTreeList1_ItemDataBound" 
    OnItemCommand="RadTreeList1_ItemCommand" EditMode="InPlace" OnItemCreated="RadTreeList1_ItemCreated"
    ViewStateMode="Enabled">
     
    <Columns>
      <telerik:TreeListBoundColumn DataField="Description" UniqueName="Description" HeaderStyle-Width="500px"
        </telerik:TreeListBoundColumn
        <telerik:TreeListTemplateColumn UniqueName="Response"
            <ItemTemplate
                <asp:DropDownList ID="ddl" runat="server">
                </asp:DropDownList>
            </ItemTemplate>
      </telerik:TreeListTemplateColumn>
    </Columns>
    </telerik:RadTreeList>

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Apr 2014, 05:17 PM
Hello Lynne,

Can you please specify how the treelist control is populated? If you are using simple data-binding calling DataBind() you will need to assign data-source and rebind the grid after each operation (expanding/collapsing, paging, sorting, etc.). If this is the case, I would recommend you handle NeedDataSource event, prepare the data source (list of objects) for Telerik RadTreeList and assign it to the treelist's DataSource property. Give this suggestions a try and let me know about the result.

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Lynne
Top achievements
Rank 1
answered on 09 Apr 2014, 06:54 PM
Hi Pavlina,

I finally found a post that answered my question. The post states "since on expand and collapse the treelist is rebound and its items are recreated, you would need to manually persist your custom selection.  You could recognize the items by DataKeyValue and use it to keep their selection in a collection in the Session or the ViewState."  The post pertained to checkboxes but I would need to do the same for my dropdownlist whose values are getting wiped out on postback. In the meantime, I was experimenting with RadTreeView and it does not appear to postback on expand/collapse so I think I'll try to use it instead of RadTreeList.  Thanks.    
0
Pavlina
Telerik team
answered on 15 Apr 2014, 01:46 AM
Hello Lynne,

In case you decide to use RadTreeList as you said you should first recognize the items by DataKeyValue. Then inside DropDownList OnSelectedIndexChange event you could save the selected value and OnPreRender event of the DropDownList control persist these values.

Regards,
Pavlina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
TreeList
Asked by
Lynne
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Lynne
Top achievements
Rank 1
Share this question
or