treeview in combobox in the listview

4 posts, 1 answers
  1. Alex
    Alex avatar
    3 posts
    Member since:
    Dec 2015

    Posted 21 Dec 2015 Link to this post

    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

     

  2. Alex
    Alex avatar
    3 posts
    Member since:
    Dec 2015

    Posted 21 Dec 2015 in reply to Alex Link to this post

    Hi, Attached is my listview

     

    Thanks,

    Alex

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alex
    Alex avatar
    3 posts
    Member since:
    Dec 2015

    Posted 21 Dec 2015 Link to this post

    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

  5. Answer
    Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 24 Dec 2015 Link to this post

    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
Back to Top