const assetTabGrid = $("#assetTabGrid").kendoTreeList({
dataSource: assetDataSource,
navigatable: false,
resizable: true,
scrollable: true,
height: 540,
editable: {
mode: "inline",
move: true,
},
dragend: function(e){
let source = this.dataItem(e.source);
let destination = this.dataItem(e.destination);
source.parentId = destination.eamCheckLineId;
},
messages:{
//用于修改默认按钮的显示文本(canceledit默认的显示文本是cancel,update默认的显示文本是update
commands:{
canceledit:"取消",
update:"保存"
}
},
dataBound: function () {
if (parent.autoResizeIframe) {
parent.autoResizeIframe('${RequestParameters.functionCode!}')
}
let rows = this.items();
let index = 0;
const idIndexMap = {};
for (let i = 0; i < rows.length; i++){
let dataItem = this.dataItem(rows[i]);
if (!dataItem.parentId){
index = index + 1;
idIndexMap[dataItem.eamCheckLineId] = index;
let rowLabel = $(rows[i]).find(".row-number");
$(rowLabel).html(index);
}else{
let parentNode = assetDataSource.get(dataItem.parentId);
let parentIndex = idIndexMap[dataItem.parentId];
let childNodes = assetDataSource.childNodes(parentNode);
for (let k = 0; k < childNodes.length; k++){
if (dataItem.eamCheckLineId == childNodes[k].eamCheckLineId){
let childIndex = parentIndex+'.'+(k + 1);
idIndexMap[dataItem.eamCheckLineId] = childIndex;
let rowLabel = $(rows[i]).find(".row-number");
$(rowLabel).html(childIndex);
}
}
}
}
},
columns: [
{
field: "",
title: '序号',
template: "<span class='row-number'></span>",
attributes: {style: "text-align:center"},
headerAttributes: {style: "text-align:center"},
width: 120
},
{
title: "编辑 | 删除",
attributes: {style: "text-align:center"},
headerAttributes: {style: "text-align:center"},
command: [
{
name: "edit",
text: "编辑",
//text: {edit: "编辑", cancel: "取消", update: "更新"}
},
{
name: "destroy",
text: "删除",
}
],
width: 120
},
],
}).data("kendoTreeList");
网友评论