1个回答
展开全部
这里是一个助手方法在Ace Admin Web应用程序框架提供我使用. .使它非常易于使用:
//IN YOUR DOCUMENT.READY()
var DataSourceTree = function (options) {
this.url = options.url;
}
DataSourceTree.prototype.data = function (options, callback) {
var self = this;
var $data = null;
var param = null
if (!("name" in options) && !("type" in options)) {
param = 0;//load the first level
}
else if ("type" in options && options.type == "folder") {
if ("additionalParameters" in options && "children" in options.additionalParameters) {
param = options.additionalParameters["id"];
}
}
if (param != null) {
$.ajax({
url: this.url,
data: 'id=' + param,
type: 'POST',
dataType: 'json',
success: function (response) {
if (response.status == "OK")
callback({ data: response.data })
},
error: function (response) {
//console.log(response);
}
})
}
};
$('#[YOURTREEVIEWID]').tree({
dataSource: new DataSourceTree({ url: '[PATH TO SERVICE]' }),
multiSelect: false,
loadingHTML: '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',
'open-icon': 'icon-minus',
'close-icon': 'icon-plus',
'selectable': true,
'selected-icon': 'icon-ok',
'unselected-icon': 'icon-remove'
});
//IN YOUR DOCUMENT.READY()
var DataSourceTree = function (options) {
this.url = options.url;
}
DataSourceTree.prototype.data = function (options, callback) {
var self = this;
var $data = null;
var param = null
if (!("name" in options) && !("type" in options)) {
param = 0;//load the first level
}
else if ("type" in options && options.type == "folder") {
if ("additionalParameters" in options && "children" in options.additionalParameters) {
param = options.additionalParameters["id"];
}
}
if (param != null) {
$.ajax({
url: this.url,
data: 'id=' + param,
type: 'POST',
dataType: 'json',
success: function (response) {
if (response.status == "OK")
callback({ data: response.data })
},
error: function (response) {
//console.log(response);
}
})
}
};
$('#[YOURTREEVIEWID]').tree({
dataSource: new DataSourceTree({ url: '[PATH TO SERVICE]' }),
multiSelect: false,
loadingHTML: '<div class="tree-loading"><i class="icon-refresh icon-spin blue"></i></div>',
'open-icon': 'icon-minus',
'close-icon': 'icon-plus',
'selectable': true,
'selected-icon': 'icon-ok',
'unselected-icon': 'icon-remove'
});
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询