JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.common.min.css">
<link rel="stylesheet" href="http://cdn.kendostatic.com/2013.2.716/styles/kendo.default.min.css">
<script src="http://cdn.kendostatic.com/2013.2.716/js/kendo.all.min.js"></script>
<input type="text" id="CashFundAccountId" class="treeview-in-dropdown k-textbox" name="CashFundAccountId" data-bind="value: CashFundAccountId" @*style="display: none;"*@ />
<textarea type="text" id="CashFundAccountIdTitle" class="treeview-in-dropdown k-textbox" data-field="CashFundAccountTitle" name="CashFundAccountIdTitle"
data-bind="value: CashFundAccountIdTitle" autocomplete="off" placeholder="введите источник..." style="width: 83%;" rows="4"></textarea>
<div id="treeview"></div>
CSS
button {
margin-bottom:2em;
}
#log {
margin-top: 3em;
}
JavaScript
var tv;
$(function () {
$tv = $("#treeview").kendoTreeView({
dataSource: [{
Name: "Furniture",
expanded: true,
items: [{
Name: "Tables & Chairs",
Id: 1
}, {
Name: "Sofas",
Id: 99
}, {
Name: "Occasional Furniture",
Id: 3
}]
}, {
Name: "Decor",
items: [{
Name: "Bed Linen",
Id: 4
}, {
Name: "Curtains & Blinds",
Id: 5
}, {
Name: "Carpets",
Id: 6
}]
}, {
Name: "Storage",
Id: 7
}],
checkboxes: {
checkChildren: true
},
check: function (e) {
getNodes(e.node);
onCheck();
},
dataTextField: "Name",
dataValueField: "Id"
}).data('kendoTreeView');
//tv.select(tv.findByName('Sofas'));
function removeStr(str, removeStr) {
if (str.indexOf(removeStr) == 0) {
str = str.substring(removeStr.length + 2);
} else {
var s1 = str.substring(0, str.indexOf(removeStr) - 1);
var s2 = str.substring(str.indexOf(removeStr) + removeStr.length);
str = str.substring(0, str.indexOf(removeStr) - 1) + str.substring(str.indexOf(removeStr) + removeStr.length);
}
return str;
};
function getNodes(node) {
//var ids = [];
var texts = [];
var item = $tv.dataItem(node);
$('#CashFundAccountId').val(item.Id);
//ids.unshift(item.Id);
texts.unshift(item.Title);
getParentsNode(node, texts);
...