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

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

9 Answers 119 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
shailesh
Top achievements
Rank 1
shailesh asked on 17 Sep 2014, 07:46 AM
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

9 Answers, 1 is accepted

Sort by
0
Accepted
Plamen
Telerik team
answered on 22 Sep 2014, 08:19 AM
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.

 
0
shailesh
Top achievements
Rank 1
answered on 23 Sep 2014, 09:27 AM
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?
0
shailesh
Top achievements
Rank 1
answered on 24 Sep 2014, 07:17 AM
<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

0
shailesh
Top achievements
Rank 1
answered on 27 Oct 2014, 01:51 PM
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
0
Plamen
Telerik team
answered on 29 Oct 2014, 02:41 PM
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.

 
0
shailesh
Top achievements
Rank 1
answered on 31 Oct 2014, 11:16 AM
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
0
Plamen
Telerik team
answered on 03 Nov 2014, 09:49 AM
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.

 
0
shailesh
Top achievements
Rank 1
answered on 03 Nov 2014, 10:26 AM
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"
0
Plamen
Telerik team
answered on 06 Nov 2014, 07:39 AM
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.

 
Tags
TreeView
Asked by
shailesh
Top achievements
Rank 1
Answers by
Plamen
Telerik team
shailesh
Top achievements
Rank 1
Share this question
or