我有一个jstree JQuery pluguin,我使用它的“checkbox”插件。我需要以编程方式选中复选框,并以编程方式禁用复选框。
我怎么能这样做?
https://groups.google.com/forum/?fromgroups#!topic/jstree/wLokkEg3eCY%5B1-25%5D我试过没有结果。
我的Jstree:
var myTree = $(tree).jstree({
"json_data": {
"ajax": {
type: "POST",
async: true,
"url": urlTree,
// data: '{"longnames":"' + flag + '"}',
data: function (n) {
id = n.attr ? n.attr("id") : prefix + '0';
reply = '{ id: "' + id + '"';
// if (dataJSON.length > 0) {
// reply = reply + ", " + dataJSON;
// }
reply += ', longnames: "' + flag + '"';
// reply += ", prefix: ";
// reply += (mutateIds != 1) ? '' : '"' + prefix + '"';
reply += "}";
return reply
},
contentType: "application/json; charset=utf-8",
dataType: "json",
cache: false,
success: function (msg) {
return msg.d.data;
},
error: function () {
// process error of ajax
return false;
}
},
// "xsl": "flat",
},
"search": {
"show_only_matches": true,
"search_method": "jstree_contains"
},
"types": {
"max_children": -2,
"max_depth": -2,
"default": {
"valid_children": ["default"],
"select_node": function (e) {
this.toggle_node(e);
return false;
}
},
"disabled" : {
"check_node" : false,
"uncheck_node" : false
}
},
"cookies": {
"save_opened": false
},
"checkbox":{
"override_ui": "true",
"real_checkboxes": "true"
},
"plugins": pluginsToUse
})
答案 0 :(得分:1)
要以编程方式检查节点,您只需执行以下操作:
$('#tree').jstree('check_node','#id');
这里#id是节点的id。