[{
"FaId": "105", "NomFa": "TREDI FA", "Idbp": "", "Nombp": "TREDI", "Iddivision": ""
},{
"FaId": "103", "NomFa": "Coframetal", "Idbp": "", "Nombp": "COFRAMETAL", "Iddivision": ""
}]
<template>
<div>
<ejs-treegrid :dataSource="tree"
:editSettings='editSettings'
:rowDataBound='rowDataBound'
:treeColumnIndex='1'
childMapping='Children'
gridLines='None'
width='auto'>
<e-columns>
<e-column
field='FaId'
headerText='FaId'
editType='dropdownedit'
:edit='filiereAvalParams'
width=180>
</e-column>
</e-columns>
</ejs-treegrid>
</div>
</template>
export default {
data() {
return {
tree: this.$store.getters.getTreeByParentID(),
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: 'Cell'
},
filiereAvalParams: {
params: {
dataSource: this.$store.state.FilliereAval,
fields: {
value: 'FaId',
text: 'NomFa'
},
allowFiltering: 'true',
query: new Query(),
actionComplete: () => false
}
},
};
},
methods: {
rowDataBound: function (args) {
if (args.data['TypeLigne'] === "FR") {
args.row.style.background = 'rgba(138, 114, 0, 0.2)';
} else if (args.data['TypeLigne'] === "FA") {
args.row.style.background = 'rgba(240, 199, 0, 0.2)';
}
if (Number.parseInt(args.data['Niveau'])) {
args.row.dataset.niveau = 'niveau';
}
},
},
provide: {
treegrid: [DetailRow, Edit]
},
}
<ejs-treegrid :dataSource="data :queryCellInfo="queryCellInfo" ref="treegrid">
<e-columns>
<e-column field="taskID" headerText="Task ID" width="100" isPrimaryKey="true"></e-column>
. . .
<e-column field="FaId" headerText="FaId" editType="dropdownedit" :edit="priorityParams" width="120" ></e-column>
</e-columns>
</ejs-treegrid>
methods: {
queryCellInfo(args) {
if (args.column.field === "FaId") {
for (var i = 0; i < priorityData.length; i++) {
let data = args.data;
if ((data[args.column.field]).toString() === priorityData[i]["FaId"]) {
args.cell.innerText = priorityData[i]["NomFa"]; // assign the foreignkey field value to the innertext
}
}
}
}
} |
<ejs-treegrid :dataSource="data" ref="treegrid" >
<e-columns>
<e-column field="taskID" headerText="Task ID" width="100" isPrimaryKey="true"></e-column>
<e-column field="taskName" :edit="params" headerText="Task Name" width="250"></e-column>
. . .
></e-column>
</e-columns>
</ejs-treegrid>
data() {
return {
editSettings: {
allowAdding: true,
allowDeleting: true,
allowEditing: true,
mode: "Cell"
},
toolbar: ["Add", "Edit", "Delete", "Update", "Cancel"],
selection: { type: "Multiple" },
params: {
create: () => {
priorityElem = document.createElement("input");
return priorityElem;
},
read: () => {
return taskObj.text;
},
destroy: () => {
taskObj.destroy();
},
write: args => {
if (args.rowData.taskName === "Planning") { // change datasource for dropdownList based on condition
data = dropData;
col = Object.keys(dropData[0]);
}
else {
data = durationData;
col = Object.keys(durationData[0]);
;
}
taskObj = new DropDownList({ //render DropdownList on write event
dataSource: data,
fields: { value: col[0]},
floatLabelType: "Never",
placeholder: "Select a Priority"
});
taskObj.appendTo(priorityElem);
}
},
|
CSS file
<style>
.e-treegrid .e-treegridexpand::before {
content: "\2795" !important;
}
.e-treegrid .e-treegridcollapse::before {
content: "\2796" !important;
}
</style> |
<ejs-treegrid :dataSource="data" :treeColumnIndex="1":showColumnMenu="true"
:queryCellInfo="queryCellInfo" ref="treegrid">
<e-columns>
<e-column field="taskID" headerText="Task ID" width="100" isPrimaryKey="true"></e-column>
. . .
</e-column>
</e-columns>
</ejs-treegrid>
methods: {
queryCellInfo(args) {
if (args.column.field === "taskName") {
if (!args.data.hasChildRecords && args.data.level !== 0) {
args.cell.classList.add("child"); // add class to differentiate childrows
}
}
}
<style>
.child {
text-indent: 35px; // add your desired indent here
}
</style>
|