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

CheckChildNodes with NodeTemplate checkbox

2 Answers 18 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Sep 2013, 04:22 PM

I'm trying to get Knockout to work the treeview so I needed to get the "data-bind" attribute added to the checkbox that is generated.

I couldn't get it to work in the NodeDataBound when using e.Node.Attributes.Add("data-bind", "myBinding: myObservableArray")...This wasn't being added to the actual HTML which Knockout needs.

So I tried using the NodeTemplate to be able to customize the HTML checkboxes.  Anyway, Child elements are checked when it's parent is using NodeTemplates with "CheckChildNodes = true"

 

<NodeTemplate>

 <input type="checkbox" value="<%# DataBinder.Eval(Container, "Id") %>" data-bind="myBinding: myObservableArray" />

....

 

 

 

 

 

2 Answers, 1 is accepted

Sort by
0
David
Top achievements
Rank 1
answered on 30 Sep 2013, 12:59 PM
If there is a way to access and modify the underlying HTML (which would be the input element in this case) I could probably get this to work  with messing with the NodeTemplate but e.Nodes.Attributes.Add doesn't work that way. 
0
Boyan Dimitrov
Telerik team
answered on 02 Oct 2013, 03:39 PM
Hello,

Thank you for contacting Telerik Support.

I would like to clarify that node's attributes collection is applied to the node object not to the check box element. Here you may find a list with the valid HTML attributes that are rendered as HTML attributes. Any other custom attributes will not be rendered as HTML attributes. I would like to clarify that even the valid HTML attributes will be applied to the node element not to the check box element.

In this case the only solution will be to use templates and set the "data-bind" attribute to the check box element within the template.

Hope that this will be helpful.

Regards,
Boyan Dimitrov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
TreeView
Asked by
David
Top achievements
Rank 1
Answers by
David
Top achievements
Rank 1
Boyan Dimitrov
Telerik team
Share this question
or