我有一個帶複選框模板的劍道樹狀圖。當我們點擊孩子複選框時,如何獲得父母的父母標識
我的HTML代碼
<div id="treeview-left" style=" height: 375px; position: absolute;top: 30px;"></div>
我定義了諸如樹視圖:
var treeview1 = $('#treeview-left').kendoTreeView({
select: onSelect,
checkboxTemplate: kendo.template($("#treeview-checkbox-template").html()),
dragAndDrop: true,
dataSource: parent,
dataTextField: ["parentName", "childName"]
}).data("kendoTreeView");
的複選框,然後模板的定義如下:
<script id="treeview-checkbox-template" type="text/kendo-ui-template">
<input type="checkbox" />
</script>
而數據源將
var parent = new kendo.data.HierarchicalDataSource({
type: "POST",
dataType: "json",
transport: {
read: {
url: "/Projects/leftdisplay"
}
},
schema: {
model: {
id: "parentid",
hasChildren: "childName",
children: child
}
}
});
現在家長的孩子會像:
var child = {
type: "POST",
dataType: "json",
transport: {
read: {
url: function (options) {
return kendo.format("/projects/modulesleftdisplay?parentid=" + options.parentid + "&roleid=" + rolevalue + "&projectid=" + projectid + "");
}
}
},
schema: {
model: {
id: "childid",
hasChildren: function() {
return false;
}
}
}
};
現在,當我點擊複選框孩子我想選擇孩子的父ID。我怎麼能得到這個。
我寫這樣的代碼
$("#treeview-left [type=checkbox]").live('change', function (e) {
var chkBox = $(this)
var parentid = chkBox.parent();
var date = $('#treeview-left').data('kendoTreeView').dataItem(parent_id);
var parid = date.id;
var childid = $('#treeview-left').data('kendoTreeView').dataItem(parentid);
});
但parid是沒有得到。我怎樣才能得到所選孩子的父母身份。任何幫助表示讚賞。
發佈你的html .. – sasi 2013-03-14 05:10:20
我編輯了我的問題 – Jonathan 2013-03-14 05:15:19
@Naidu,檢查一個基本問題:當你計算'date'時,什麼是'treeview'?它是'treeview'還是'treeview-left' ?. – OnaBai 2013-03-14 09:29:37