Need to add runtime dropdownbox/combobox as a child node in TreeView

10 posts, 1 answers
  1. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 17 Sep 2014 Link to this post

    Hi,

    I have a requirement where I need to add runtime combobox/dropdownbox as a
    child element of every parent node of TreeView control.

    Data inside the combobox/dropdownbox will be fetched from Database and it will
    be same for all the combobox/dropdownbox control.

    Parent Node will be a simple text which also be fetch from the Database...

    Kindly let me know how to achieve this functionality.

    Regards,
    Shailesh

  2. Answer
    Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 22 Sep 2014 Link to this post

    Hi Shailesh,

    You can achieve such functionality by adding templates at run time to RadTreeView and add the desired RadComboBox or RadDropDownList from there as it is described in this help topic.

    Hope this will help you solve the issue.


    Regards,
    Plamen
    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 23 Sep 2014 in reply to Plamen Link to this post

    Hi Plamen,

    Thanks for response.

    See, I have loaded the data in RadCombobox (child node) under the RadTreeView ...Once it is done I am trying to retrieve the values of parent node and child node values (Selected value from RadCombobox) in "Save" button....


    How can we do that?
  5. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 24 Sep 2014 Link to this post

    <telerik:RadTreeView ID="RadTreeView1" runat="server" AllowNodeEditing="true" OnContextMenuItemClick="RadTreeView1_ContextMenuItemClick"
                                OnNodeEdit="RadTreeView1_NodeEdit" OnClientContextMenuItemClicking="onClientContextMenuItemClicking"
                                OnClientContextMenuShowing="onClientContextMenuShowing" OnNodeCreated="RadTreeView1_NodeCreated" Expanded="true">
                                <Nodes>
                                    <telerik:RadTreeNode Expanded="true">
                                      <NodeTemplate>
                                            <telerik:RadComboBox ID="cmbMultiMedia"  runat="server" Width="200px" Text='<%# Eval("MediaFileName").ToString()== "" ? "-----None-----": Eval("MediaFileName").ToString() %>' ></telerik:RadComboBox>
                                            <%--<telerik:RadComboBox ID="cmbMultiMedia"  runat="server" Width="200px"></telerik:RadComboBox>--%>
                                      </NodeTemplate>
                                      </telerik:RadTreeNode>
                              </Nodes>
                            </telerik:RadTreeView>

    Binding the Data....

    if (noOfPages > 0)
                   {
                       for (int i = 1; i <= noOfPages; i++)
                       {
                           MobileBoardReaderBL.MultiMediaLinkService proxyLoad = new MobileBoardReaderBL.MultiMediaLinkService();
                           List<MobileBoardReaderPL.BoardBookMediaLinkProperties> MediaData = proxyLoad.GetMediaLinkByBookId(new Guid(Session["SelectedBookId"].ToString()));
     
     
                           //IRadTreeNodeContainer target = treeView;
     
                           RadTreeNode root = new RadTreeNode();
                           root.AllowEdit = false;
                           root.Text = "Page " + i;
     
                           RadComboBox cmbMultiMedia = (RadComboBox)treeView.FindControl("cmbMultiMedia");
     
     
                           //RadTreeNode child1 = root.Nodes[i];
     
     
                           //RadTreeNode root = new RadTreeNode();
                           //root.AllowEdit = false;
                           //root.Text = "Page " + i;
     
                           RadTreeNode child1 = new RadTreeNode("child1");
                           cmbMultiMedia = new RadComboBox();
                           //RadComboBox radcmb = new RadComboBox();
                           //RadComboBoxItem items = new RadComboBoxItem("testcmb");
     
                           MobileBoardReaderPL.BoardBookMediaLinkProperties firstRec = new MobileBoardReaderPL.BoardBookMediaLinkProperties();
                           firstRec.MediaFileName = "-----None-----";
     
                           List<MobileBoardReaderPL.BoardBookMediaLinkProperties> data = new List<MobileBoardReaderPL.BoardBookMediaLinkProperties>();
                           foreach (MobileBoardReaderPL.BoardBookMediaLinkProperties v in MediaData)
                           {
                               data.Add(v);
                           }
                           data.Insert(0, firstRec);
     
                           cmbMultiMedia.Items.Clear();
                           cmbMultiMedia.DataSource = data;
                           cmbMultiMedia.DataTextField = "MediaFileName";
                           cmbMultiMedia.DataValueField = "MediaFileName";
                           cmbMultiMedia.DataBind();
     
                           child1.Controls.Add(cmbMultiMedia);
                           root.Nodes.Add(child1);
     
                           treeView.Nodes.Add(root);
                            
                       }
                   }

    I want to retrieve the Value of Parent & Child Node
    (Selected Value of RadComboBox)..

    ----------------------------------------------------------------------------------------
    Again Requirement is :
    ===================

    1) Need to populated TreeView from Database..
    2) Parent Node - will be value like (Page 1, Page 2, .....)
    3) Child node - RadComboBox ----will have multiple Values..
    4) Save Button ---
         4.1) Selected Value from radcombobox will be set  as a Lable in every Childnode in TreeView
         4.2) Need to read the values from TreeView by traversing Parent & Child Nodes.
    5) Edit Button - click On this ..Child Node - label Control will become to RadComboBox....
         5.1) Edit button - should become Save button...
    6) Cancel button - Click on this it will retain the previous values..

    Kindly help me to provide your input at the earliest. if possible can u please develop sample application and share with me..

    Regards,
    Shailesh

  6. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 27 Oct 2014 in reply to shailesh Link to this post

    I am able to achieve required functionality, But i have doubt on my coding....

    I have TreeView Bindling function which I am using it 2 times in Page load event...
    if (!Page.IsPostBack)
    {
       Binding Treeview 
    }
    else
    {
        Binding Treeview 
    }

    The reason of using it in "else" because when I click on Save button...it looses the binding....


    Greatly appreciate your response on why it is loosing the binding while click on save button?

    Regards,
    Shailesh
  7. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 29 Oct 2014 Link to this post

    Hello Shailesh,

    It looks like the unusual behavior is caused by the way you add your RadComboBox inside the TreeView. Please review to this help topic where is described how we recommend adding the templates at runtime.

    Hope this information will help you solve the issue.

    Regards,
    Plamen
    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.

     
  8. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 31 Oct 2014 in reply to Plamen Link to this post

    Thanks Telerik,

    I have gone through the help topic and observed that Treeview Node binding is happeing everytime when page gets load. is that the correct way as I am doing the same thing?

    Regards,
    Shailesh
  9. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 03 Nov 2014 Link to this post

    Hello,

    Yes this is the way we recommend adding templates to the nodes.

    Regards,
    Plamen
    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.

     
  10. shailesh
    shailesh avatar
    6 posts
    Member since:
    Sep 2014

    Posted 03 Nov 2014 in reply to Plamen Link to this post

    Thanks Plamen for your response!!!

    Now, I am facing an below issue. can you please see how can we solve?

    1) I have Cancel button which will reselect the right values which are store in Database. it gets remain the select value (user select )from RCBComboBox..
         1.1)  Let's say.....I have 3 values in Combobox like "AB", "CD" and "EF" and it gets set value as "CD" when first time page loads because "CD" values stores and retrieve from Database..
         1.2) Now, User wants to change value from "CD" to "EF" and before click on "Save" button - he/she changes his/her mind and wanted to retain old value as "CD" by click on "Cancel" button...but it doesnot clear selected value as "EF" from RCBComboBox eventhough we call Database query to select right value"
  11. Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 06 Nov 2014 Link to this post

    Hi,

    Sounds like a scenario that is custom for your scenario. in such case I would kindly recommend you to isolate the issue into a sample project and submit a support ticket.

    Regards,
    Plamen
    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.

     
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017