Click here to Skip to main content
15,885,537 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
We have a kendo tree-view already implemented in our web application. In our new requirement we have to add some additional controls inside tree view.

>>    Scenario 1: Once user select a check box from tree view one textbox should be shown near to selected checkbox (based on some business logic). The required data for control will be there in JS object.

>>    Scenario 2: Once user select a check box from tree view one combo box should be shown near to selected checkbox (based on some business logic). The required data for control will be there in JS object. These controls should be created at any level of tree view (based on certain business logic which is already there in code)

I am looking for an inbuilt functionality in kendo-ui where I can add textbox or combo-box inside the tree-view control. 


What I have tried:

I go through a lot of threads available on kendo site but not get any similar implementation.
Posted
Updated 16-Feb-17 9:49am
Comments
Karthik_Mahalingam 14-Feb-17 5:57am    
it would be better to build a custom control rather than digging kendo library to customize it.
Valery Possoz 16-Feb-17 15:51pm    
You have a point but Kendo is pretty nice when used correctly. See my answer below.
Karthik_Mahalingam 16-Feb-17 22:20pm    
you have got a solution.

1 solution

Hello,

It is pretty simple, just use the checkbox template, a bit of css and javascript.
I have uploaded a sample here:
Kendo UI® Dojo by Progress[^]

First in CSS define two class to show or hide the box:

<style type="text/css">
.txtBoxHidden{
  display:none;
}
.txtBoxVisible{
  display:inline;
}
</style>


Then in the script loading the tree add a little javaScript:

<script>
  
$("#treeview").kendoTreeView({
  checkboxes: {
    template: "<input type='checkbox' name='checkedFiles[#= item.id #]' value='true' id='#= item.id #' /><input type='text' class='txtBoxHidden' id='txtEditBox#= item.id #'/>"
  },
  dataSource: [
    { id: 1, text: "foo", items: [
      { id: 2, text: "bar" }
    ] }
  ]
});
  
$(':checkbox').change(function() {
    var id = 'txtEditBox' + $(this).attr('id');
    var className = document.getElementById(id).className; 
    if (className == 'txtBoxHidden') {
	  	document.getElementById(id).className = 'txtBoxVisible';
    }
    else {
	  	document.getElementById(id).className = 'txtBoxHidden';
    }
});
  
</script>


Tada!

Valery
 
Share this answer
 
Comments
NileshKRathod 17-Feb-17 2:30am    
Thanks for giving me idea about it. I will implement it based on the idea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900