我基于这个IgniteUI教程创建了一个拖放树列表。树列表工作得很好,但问题出在孩子身上。如图所示,我在孩子中变得不确定
这是我的 ts 代码:
this.options = {
checkboxMode: 'triState',
singleBranchExpand: true,
dataSource: jQuery.extend(true, [], this.ServiceCounterPointRelations),
dataSourceType: 'json',
initialExpandDepth: 2,
pathSeparator: '.',
bindings: {
textKey: 'ServiceCounter',
valueKey: 'ServiceCounterId',
childDataProperty: 'ServicePoints'
},
dragAndDrop: true,
dragAndDropSettings: {
allowDrop: true,
customDropValidation: function (element) {
var valid = true,
droppableNode = jQuery(this);
if (droppableNode.is('a') && droppableNode.closest('li[data-role=node]').attr('data-value') === 'File') {
valid = false;
}
return valid;
}
}
};
this.ServiceCounterPointRelations包含以下 json
"ServiceCounterPointRelations": [
{
"ServiceCounterId": 2,
"ServiceCounter": "Main Counter",
"ServicePoints": [
{
"ServicePointId": 2,
"ServicePoint": "Service Point 1"
}
]
},
{
"ServiceCounterId": 3,
"ServiceCounter": "Counter 1",
"ServicePoints": []
},
{
"ServiceCounterId": 4,
"ServiceCounter": "Test for 2",
"ServicePoints": []
},
{
"ServiceCounterId": 5,
"ServiceCounter": "ASD",
"ServicePoints": [
{
"ServicePointId": 1,
"ServicePoint": "DER"
},
{
"ServicePointId": 3,
"ServicePoint": "ER"
}
]
},
{
"ServiceCounterId": 6,
"ServiceCounter": "ASD",
"ServicePoints": []
},
{
"ServiceCounterId": 7,
"ServiceCounter": "EEE",
"ServicePoints": []
},
{
"ServiceCounterId": 8,
"ServiceCounter": "With New Tog",
"ServicePoints": []
}
]
我找到了问题,但我仍在寻找修复程序。问题是我只将父textKey 绑定为 'ServiceCounter' 和 valueKey 作为 'ServiceCounterId'。但是孩子有不同的textKey和valueKey。我不知道该怎么做。任何意见将是有益的。谢谢。