const parentdata = [
{
TaskID: 1,
TaskName: "Parent Task 1",
StartDate: new Date("02/23/2017"),
EndDate: new Date("02/27/2017"),
Duration: 3,
Progress: "40",
Priority: "Normal",
hasChildData: true
}
];
const childdata = [
{
TaskID: 2,
TaskName: "Child Task 1",
StartDate: new Date("02/23/2017"),
EndDate: new Date("02/27/2017"),
Duration: 4,
Progress: "40",
parentID: 1,
Priority: "Low"
},
{
TaskID: 3,
TaskName: "Child Task 2",
StartDate: new Date("02/23/2017"),
EndDate: new Date("02/27/2017"),
Duration: 2,
Progress: "40",
parentID: 1,
Priority: "Normal"
}
];
const treeGrid = new TreeGrid({
dataSource: { result: parentdata, count: parentdata.count },
hasChildMapping: "hasChildData",
treeColumnIndex: 1,
idMapping: "TaskID",
parentIdMapping: "parentID",
dataStateChange: function(state: any) {
if (state.requestType === "expand") {
state.childData = childdata;
state.childDataBind();
} else {
this.dataSource = { result: childdata, count: childdata.count };
}
},
columns: [
{ field: "TaskID", headerText: "Task ID", textAlign: "Right", width: 140 },
{ field: "TaskName", headerText: "Task Name", width: 160 },
{
field: "StartDate",
headerText: "Start Date",
textAlign: "Right",
width: 120,
format: { skeleton: "yMd", type: "date" }
},
{
field: "EndDate",
headerText: "End Date",
textAlign: "Right",
width: 120,
format: { skeleton: "yMd", type: "date" }
},
{
field: "Duration",
headerText: "Duration",
textAlign: "Right",
width: 110
},
{
field: "Progress",
headerText: "Progress",
textAlign: "Right",
width: 110
},
{ field: "Priority", headerText: "Priority", width: 110 }
]
});
|