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

treeview in combobox in the listview

3 Answers 74 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 21 Dec 2015, 03:00 PM

Hi team,

 I am having listview, I want to add treeview inside listview.

And the listview should be combobox same like in this demo

Treeview in Combobox

 

Please help me how to do this.

aspx page

 

<telerik:RadListView ID="rlvUsers" runat="server"
                              ItemPlaceholderID="EmployeesContainer" DataKeyNames="userid" OnItemDataBound="rlvUsers_ItemDataBound">
                              <LayoutTemplate>
                                  <fieldset>
                                      <legend>New Employees - Manage Profiles</legend>
                                      <asp:PlaceHolder ID="EmployeesContainer" runat="server"></asp:PlaceHolder>
                                  </fieldset>
                              </LayoutTemplate>
                              <ItemTemplate>
                                  <fieldset>
                                      <legend class="gray"><%#Eval("fullName")%></legend>
                                      <table style="line-height: 30px; padding: 60px; width: 100%">
                                          <tr>
                                              <td style="width: 120px">
                                                  <asp:Label ID="Label1" runat="server" CssClass="ax-text-gray" Text="Employee Code"></asp:Label>
                                              </td>
                                              <td>
                                                  <asp:Label ID="Label2" runat="server" CssClass="ax-input-noborder" Text='<%#Eval("empid")%>'></asp:Label>
                                              </td>
                                              <td style="width: 50px"></td>
                                              <td style="width: 120px">
                                                  <asp:Label ID="Label7" runat="server" CssClass="ax-text-gray" Text="Select Parent"></asp:Label>
                                              </td>
                                              <td>
                                                  <telerik:RadComboBox ID="cbParent" runat="server" Width="400px" >
                                                      <ItemTemplate>
                                                          <telerik:RadTreeView ID="rTreeParent" runat="server" DataFieldID="userid" DataFieldParentID="parent_id"
                                                              DataTextField="fullName" DataValueField="userid"  >
                                                          </telerik:RadTreeView>
                                                      </ItemTemplate>
                                                  </telerik:RadComboBox>
                                              </td>
                                              <td rowspan="3">
                                                  <asp:Button ID="btnAssignProfiles" CssClass="btn btn-circle btn-sky" runat="server" Text="Assign" />
                                              </td>
                                          </tr>                                         
                                      </table>
                                      <br />
                                      <br />
                                  </fieldset>
                              </ItemTemplate>
  
                          </telerik:RadListView>

code behind

 

protected void rlvUsers_ItemDataBound(object sender, RadListViewItemEventArgs e)
     {
         if (e.Item.ItemType == RadListViewItemType.DataItem || e.Item.ItemType == RadListViewItemType.AlternatingItem)
         {
             RadListViewItem item = e.Item as RadListViewItem;
             RadComboBox cbParent = (RadComboBox)item.FindControl("cbParent");
             cbParent.DataSource = getActiveUsers();
             cbParent.DataBind();
         }
     }

 

Now it is loading in combo box. But I wan this in tree inside combobox

 

Thanks

Alex

 

3 Answers, 1 is accepted

Sort by
0
Alex
Top achievements
Rank 1
answered on 21 Dec 2015, 03:06 PM

Hi, Attached is my listview

 

Thanks,

Alex

0
Alex
Top achievements
Rank 1
answered on 22 Dec 2015, 05:49 AM

Dears,

I have replaced with raddropdowntree. And it is working for me. Thanks

Attached : image of working list view

Aspx 

 

<td>
                                  <telerik:RadDropDownTree ID="ddTreeParent" runat="server" DefaultMessage="Select Parent..." ExpandNodeOnSingleClick="true"
                                      EnableFiltering="true" FilterSettings-Highlight="Matches" Width="400px">
                                      <DropDownSettings OpenDropDownOnLoad="true" />
                                  </telerik:RadDropDownTree>
                              </td>

Code behind

 

protected void rlvUsers_ItemDataBound(object sender, RadListViewItemEventArgs e)
       {
           if (e.Item.ItemType == RadListViewItemType.DataItem || e.Item.ItemType == RadListViewItemType.AlternatingItem)
           {
               RadListViewItem item = e.Item as RadListViewItem;
               //RadComboBox cbParent = (RadComboBox)item.FindControl("cbParent");
               //cbParent.DataSource = getActiveUsers();
               //cbParent.DataBind();
 
               RadDropDownTree treeParent = (RadDropDownTree)item.FindControl("ddTreeParent");
               treeParent.DataFieldID = "userid";
               treeParent.DataFieldParentID = "parent_id";
               treeParent.DataValueField = "userid";
               treeParent.DataTextField = "fullName";
               treeParent.DataSource = getActiveUsers();
               treeParent.DataBind();
           }
       }

 

Regards

Alex

0
Accepted
Eyup
Telerik team
answered on 24 Dec 2015, 08:54 AM
Hello Alex,

Thank you for sharing your approach with our community.
Alternatively, you can also use the DataBinding event handler of the dropdowntree and access the container item using (sender as RadDropDownTree).NamingContainer. This way, you will prevent calling the DataBind() method manually.

Regards,
Eyup
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
Tags
TreeView
Asked by
Alex
Top achievements
Rank 1
Answers by
Alex
Top achievements
Rank 1
Eyup
Telerik team
Share this question
or