tree的数据源怎么绑定??希望有人知道,附代码
var DataSourceTree = function(options) {this._data = options.data;this._delay = options.delay;}
DataSourceTree.prototype.data = function(options, callback) {var self = this;var $data = null;
if (!("name" in options) && !("type" in options)) {$data = this._data;callback({data : $data});return;} else if ("type" in options && options.type == "folder") {if ("additionalParameters" in options && "children" in options.additionalParameters)$data = options.additionalParameters.children;else$data = {}}
if ($data != null)setTimeout(function() {callback({data : $data});}, parseInt(this._delay));
console.log($data);
};
var remoteUrl = hostDomain + "/admin/yuding/distributionpoint/area/areaTreeJson";var tree_data = null;$.ajax({url : remoteUrl,data : {},type : 'GET',async : false,dataType : 'json',success : function(response) {if (response.success == true) {var treeJson = response.treeJson;if (treeJson != null) {tree_data = treeJson.data;}}},error : function(response) {console.log(response);}});console.log(tree_data);
var treeDataSource = new DataSourceTree({'data' : tree_data,'delay' : '300'});
$('#jq_arealist').ace_tree({'dataSource' : treeDataSource,'multiSelect' : true,'loadingHTML' : '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',// 'open-icon' : 'icon-minus',// 'close-icon' : 'icon-plus','selectable' : true,'cacheItems' : true,'folderSelect' : true,'selected-icon' : 'icon-ok','unselected-icon' : 'icon-remove'});
$('#submit-button').on('click', function() {var output = '';var itemIds = $('#jq_arealist').tree('selectFolder', $('#itemId'));for ( var i in itemIds)if (itemIds.hasOwnProperty(i)) {var item = itemIds[i];output += item.additionalParameters['id'] + ":" + item.name + "n";}alert(output);// var items = $('#jq_arealist').tree('selectedItems');// for ( var i in items)// if (items.hasOwnProperty(i)) {// var item = items[i];// output += item.additionalParameters['id'] + ":" + item.name + "n";// }// alert(output);});
不同语言有不同工具
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(2)
var DataSourceTree = function(options) {
this._data = options.data;
this._delay = options.delay;
}
DataSourceTree.prototype.data = function(options, callback) {
var self = this;
var $data = null;
if (!("name" in options) && !("type" in options)) {
$data = this._data;
callback({
data : $data
});
return;
} else if ("type" in options && options.type == "folder") {
if ("additionalParameters" in options && "children" in options.additionalParameters)
$data = options.additionalParameters.children;
else
$data = {}
}
if ($data != null)
setTimeout(function() {
callback({
data : $data
});
}, parseInt(this._delay));
console.log($data);
};
var remoteUrl = hostDomain + "/admin/yuding/distributionpoint/area/areaTreeJson";
var tree_data = null;
$.ajax({
url : remoteUrl,
data : {},
type : 'GET',
async : false,
dataType : 'json',
success : function(response) {
if (response.success == true) {
var treeJson = response.treeJson;
if (treeJson != null) {
tree_data = treeJson.data;
}
}
},
error : function(response) {
console.log(response);
}
});
console.log(tree_data);
var treeDataSource = new DataSourceTree({
'data' : tree_data,
'delay' : '300'
});
$('#jq_arealist').ace_tree({
'dataSource' : treeDataSource,
'multiSelect' : true,
'loadingHTML' : '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',
// 'open-icon' : 'icon-minus',
// 'close-icon' : 'icon-plus',
'selectable' : true,
'cacheItems' : true,
'folderSelect' : true,
'selected-icon' : 'icon-ok',
'unselected-icon' : 'icon-remove'
});
$('#submit-button').on('click', function() {
var output = '';
var itemIds = $('
#jq_arealist').tree('selectFolder', $('#itemId'));
for ( var i in itemIds)
if (itemIds.hasOwnProperty(i)) {
var item = itemIds[i];
output += item.additionalParameters['id'] + ":" + item.name + "n";
}
alert(output);
// var items = $('#jq_arealist').tree('selectedItems');
// for ( var i in items)
// if (items.hasOwnProperty(i)) {
// var item = items[i];
// output += item.additionalParameters['id'] + ":" + item.name + "n";
// }
// alert(output);
});
不同语言有不同工具