On the right is to click on the left element and get node.data.cols, then render it dynamically, and then I want to change the value of the element node.data.cols on the right. According to my code, I will change the node.data.cols value of other elements on the canvas. Can I see what the reason is?
_designer.addDiagramListener(“ObjectSingleClicked”, onObjectSingleClicked);
function onObjectSingleClicked(ev) {
var part = ev.subject.part;
showEditNode(part);
};
function showEditNode(node) {
for (var obj in node.data.cols){
if(node.data.cols[obj].type == ‘checkbox’){//判断多选框
var checkboxCheckedStr = ‘’;
if(node.data.cols[obj].value == false){
checkboxCheckedStr = “checked = checked”;
};
var colsCheckbox = ’
<input class=“pull-left” ’ + checkboxCheckedStr + ’ type=“checkbox”>
’ + node.data.cols[obj].text + ’
‘;
('.field-settings').append(colsCheckbox);
}else if(node.data.cols[obj].type == 'select'){//判断下拉框框append进去
var optionHtml='';
for(var i=0;i<node.data.cols[obj].selectParams.length;i++){
var selectP = node.data.cols[obj].selectParams;
optionHtml += '<option value="' + selectP[i].value + '">' + selectP[i].name + '</option>';
}
var colsOptionSelect = '<div class="split-parameter">\
<div class="split-proportion">\
<h4 class="proportion-title">' + node.data.cols[obj].text + '</h4>\
<select style="width:100%;" id="' + node.data.cols[obj].id + '" value=' + node.data.cols[obj].value + '>\
' + optionHtml + '</select>\
</div>\
</div>';
(’.field-settings’).append(colsOptionSelect);
$(’#’ + node.data.cols[obj].id).select2().val(node.data.cols[obj].value).trigger(‘change’);
changeDataCols(node.data.cols[obj].id,obj)
}
}
}
function changeDataCols(id,obj){
('#' + id).on('change',function(){
var selectVal = (this).val();
_designer.startTransaction(“vacate”);
_designer.model.setDataProperty(nodeCur.data.cols[obj], “value”, selectVal);
_designer.commitTransaction(“vacate”);
//_designer.removeChangedListener(onObjectSingleClicked);
})
}
nodeDataArray like this:
“nodeDataArray”: [{
“category”: “gyh”,
“text”: “归一化”,
“images”: “images/guiyihua.png”,
“model_name”: “normalization”,
“cols”: {
“1”: {
“text”: “是否保留原始列”,
“value”: true,
“type”: “checkbox”
},
“2”: {
“text”: “input框”,
“value”: “1”,
“type”: “input”
},
“3”: {
“text”: “选择表名”,
“value”: “1”,
“type”: “select”,
“id”: “optionSelect”,
“selectParams”: [{
“id”: “0”,
“name”: “所有字段”,
“value”: 1
}, {
“id”: “2”,
“name”: “two”,
“value”: 2
}, {
“id”: “3”,
“name”: “three”,
“value”: 3
}]
},
“4”: {
“text”: “选择字段”,
“value”: [“1”, “2”],
“id”: “selectfeild”,
“type”: “selectfeild”,
“feildParams”: [{
“id”: “0”,
“name”: “所有字段”,
“type”: 100
}, {
“id”: “2”,
“name”: “two”,
“type”: 1
}, {
“id”: “3”,
“name”: “three”,
“type”: 1
}]
},
“5”: {
“text”: “源表字段信息”,
“type”: “table”,
“feildParams”: [{
“id”: “0”,
“name”: “所有字段”,
“type”: “STRING”
}, {
“id”: “2”,
“name”: “two”,
“type”: “STRING”
}, {
“id”: “3”,
“name”: “three”,
“type”: “STRING”
}]
},
“componentExplain”: {
“type”: “explain”,
“text”: “归一化”,
“content”: “可以选择是否保留原始列,勾选后原始列会被保留,处理过的列重命名 可以选择是否保留原始列,勾选后原始列会被保留,处理过的列重命名”
}
},
“key”: -1,
“loc”: “260 -60”
},
{
“category”: “gyh”,
“text”: “归一化”,
“images”: “images/guiyihua.png”,
“model_name”: “normalization”,
“cols”: {
“1”: {
“text”: “是否保留原始列”,
“value”: true,
“type”: “checkbox”
},
“2”: {
“text”: “input框”,
“value”: “1”,
“type”: “input”
},
“3”: {
“text”: “选择表名”,
“value”: “1”,
“type”: “select”,
“id”: “optionSelect”,
“selectParams”: [{
“id”: “0”,
“name”: “所有字段”,
“value”: 1
}, {
“id”: “2”,
“name”: “two”,
“value”: 2
}, {
“id”: “3”,
“name”: “three”,
“value”: 3
}]
},
“4”: {
“text”: “选择字段”,
“value”: [“1”, “2”],
“id”: “selectfeild”,
“type”: “selectfeild”,
“feildParams”: [{
“id”: “0”,
“name”: “所有字段”,
“type”: 100
}, {
“id”: “2”,
“name”: “two”,
“type”: 1
}, {
“id”: “3”,
“name”: “three”,
“type”: 1
}]
},
“5”: {
“text”: “源表字段信息”,
“type”: “table”,
“feildParams”: [{
“id”: “0”,
“name”: “所有字段”,
“type”: “STRING”
}, {
“id”: “2”,
“name”: “two”,
“type”: “STRING”
}, {
“id”: “3”,
“name”: “three”,
“type”: “STRING”
}]
},
“componentExplain”: {
“type”: “explain”,
“text”: “归一化”,
“content”: “可以选择是否保留原始列,勾选后原始列会被保留,处理过的列重命名 可以选择是否保留原始列,勾选后原始列会被保留,处理过的列重命名”
}
},
“key”: -4,
“loc”: “360 -70”
}
],