public toolbarClick(args: any) {
if (args.item.id === this.gantt.element.id+"_edit") {
args.cancel = true;
// you can initialize and show your custom edit dialog here
if(this.gantt.selectedRowIndex != -1) {
this.rowData = this.gantt.currentViewData[this.gantt.selectedRowIndex];
}
this.renderDialog(this.rowData);
}
// you can initialize and show your custom add dialog here
if (args.item.id === this.gantt.element.id+"_add") {
args.cancel = true;
this.renderAddDialog();
}
}
public actionBegin(args: any) {
if (args.requestType == 'beforeOpenEditDialog') {
args.cancel = true;
// you can initialize and show your custom dialog here
if(this.gantt.selectedRowIndex != -1) {
this.rowData = this.gantt.currentViewData[this.gantt.selectedRowIndex];
}
this.renderDialog(this.rowData);
}
// you can initialize and show your custom add dialog here
else if (args.requestType == 'beforeOpenAddDialog') {
args.cancel = true;
this.renderAddDialog();
}
}
public okButton: EmitType<object> = () => {
var tasknameObj = document.getElementById("taskname") ;
this.gantt.updateRecordByID({TaskID:this.rowData.TaskID, TaskName:tasknameObj.value});
this.editdialog.hide();
}
public cancelButton: EmitType<object> = () => {
this.editdialog.hide();
}
public addokButton: EmitType<object> = () => {
debugger;
var tasknameObj = (document.getElementById("taskName") as any).ej2_instances[0];
let obj: any = document.getElementById('contextMenu').ej2_instances[0];
let currentId: any = (parseInt(obj.ids[obj.ids.length-1])+1).toString();
let record: object = {
TaskName: tasknameObj.value,
TaskID: currentId
};
this.gantt.addRecord(record);
tasknameObj.value = "";
this.adddialog.hide();
}
public addcancelButton: EmitType<object> = () => {
this.adddialog.hide();
} |
[app.component.ts]
public renderDialog(data) {
this.editdialog.show();
var customObj = (document.getElementById("custom") as any);
customObj.innerHTML = "";
var liElement;
var t;
for (var a = 0; a < data.ganttProperties.resourceInfo.length; a++) {
// Create li element for each resource and append
liElement = document.createElement("LI");
t = document.createTextNode(data.ganttProperties.resourceInfo[a].resourceName);
liElement.appendChild(t);
customObj.appendChild(liElement);
}
}
[app.component.html]
< ejs - dialog id = "editdialog" #editdialog >
<ng-template #content>
…./////
<ul id="custom"></ul>
</ng - template >
</ejs - dialog > |