我试过两棵树,它们的数据是从 json 加载的。每当我使用 json 加载拖放时,都无法按预期工作。该事件始终采用第二棵树。
我尝试从 TreeA 中拖动一个元素,但它从 TreeB 中获取元素。您可以从树下显示的标签中看到哪个被拖动
如果 TreeB 中没有与 TreeA 一样的相应元素,则 TreeA 元素被拖动
我想不通。我认为有些事情与只存储第二个树数据的对象有关..任何帮助将不胜感激:)
下面是相同的小提琴演示
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
});
}