我试过两棵树,它们的数据都是从json加载的。无论何时我使用json,加载,拖放都不能像预期的那样工作。事件总是取第二棵树。
我尝试从TreeA中拖动一个元素,但是它从TreeB .You中获取元素,可以看到哪个元素被从树下显示的标签中拖动。
如果TreeB中没有与TreeA相同的相应元素,则TreeA元素将被拖动。
我搞不懂。我认为与只存储第二棵树data..Any帮助的对象有关的是:)
下面是同样的小提琴演示
http://jsfiddle.net/tgb1ecLx/
function source(data) {
var source = {
datatype: "json",
datafields: [{
name: 'id'
}, {
name: 'parentid'
}, {
name: 'text'
}, {
name: 'value'
}, {
name: 'expanded'
}],
id: 'id',
localdata: data
};
// create data adapter.
dataAdapter = new $.jqx.dataAdapter(source);
// perform Data Binding.
dataAdapter.dataBind();
// get the tree items. The first parameter is the item's id. The second parameter is the parent item's id. The 'items' parameter represents
// the sub items collection name. Each jqxTree item has a 'label' property, but in the JSON data, we have a 'text' field. The last parameter
// specifies the mapping between the 'text' and 'label' fields.
var records = dataAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{
name: 'text',
map: 'label'
}]);
// if(tree="fact")
$('#treeA').jqxTree({
source: records
});
}发布于 2014-08-25 18:16:36
拖放函数的主要问题是不能区分两种树状视图。
我将所有ID值增加到100。(关于TreeB的数据)现在作业已经正确完成了。
我希望这能帮到你。
http://jsfiddle.net/tgb1ecLx/10/
data = [
{ "id": "102",
"parentid": "101",
"text": "Tree B Hot Chocolate",
"value": "$2.3"
}, {
"id": "103",
"parentid": "101",
"text": "Tree B Peppermint Hot Chocolate",
"value": "$2.3"
}, {
"id": "104",
"parentid": "101",
"text": "Tree B Salted Caramel Hot Chocolate",
"value": "$2.3"
}, {
"id": "105",
"parentid": "101",
"text": " Tree B White Hot Chocolate",
"value": "$2.3"
}, {
"text": "Tree B Chocolate Beverage",
"id": "101",
"parentid": "-1",
"value": "$2.3"
}
]; https://stackoverflow.com/questions/25205842
复制相似问题