$("#gantt").ejGantt({
//...
actionBegin: function (args) {
if (args.requestType == "openEditDialog") {
var ganttObj = $("#gantt").ejGantt("instance");
var obj = $("#treegrid" + ganttObj._id + "resourceEdit").ejTreeGrid("instance");
obj.model.beginEdit = function (args) {
var columns = this.model.columns;
var resources = [
{ resourceId: 1, resourceName: "Project Manager" },
{ resourceId: 2, resourceName: "Software Analyst" },
]; // New resource collection
var dropDownData = columns[0].dropdownData = $.extend(true, [], resources);
var dataSource = this.model.dataSource;
var value = args.data.item.name;
for (var i = 0; i < dataSource.length; i++) {
if (value != dataSource[i].name) {
var index = $.map(dropDownData, function (data, index) {
if (data["resourceId"].toString() == dataSource[i].name) {
return index;
}
});
dropDownData.splice(index[0], 1);
}
}
if (dropDownData.length <= 1) {
ganttObj.enbleDisableAddResourceButton('disable', "beginEdit");
}
}
}
},
}); |