Raja
Thanks for update.
I am calling RebindPropertychange many places like when calling any function from context menu for add/Delete/ Making child/ Indent/ Outdent/Insert New Task Below/MoveItemDown/MoveItemUp and in callback of these calling RebindPropertychange() and in that calling ChangeNotifier(sender, args) in that calling my server side function to save data.
let me share you some code for Add Item using context Menu.
//Added Add Item in context menu
var tableContextMenu = gantt.TableContextMenu;
// Add context menu
var tableMenuItems = [
{
keyName: "AddItem",
name: "Add Task",
icon: "Add Item",
callback: function (key, opt) {
AddNewTaskRow(gantt, key, opt);
}
}
]
tableContextMenu.AddNewItems(tableMenuItems, false);
//To add a task.
function AddNewTaskRow(gantt) {
var newTask = getNewTask();
addedTasks.Add(newTask.ID, newTask);
gantt.AddNewItem(newTask);
addnewrow = "Y";
ShowHideGanttColumn();
RebindPropertychange();
adduprBlowRow = "";
updatedTasks.Add(newTask.ID, newTask);
}
function RebindPropertychange() {
//debugger;
var activityViews = gantt.Model.AllActivities;
for (var i = 1; i <= activityViews.length; i++) {
var view = activityViews;
//var activity = ganttControl.ActivityViews.activity;
var activity = gantt.Model.AllActivities;
var task = activity.DataSource;
//To listen the task changes.
task.PropertyChanged.subscribe(ChangeNotifier);
}
}
function ChangeNotifier(sender, args) {
var timer = null;
if (adduprBlowRow != 'y') {
var timer;
if (!addedTasks.Contains(sender.ID) && args.PropertyName != "SortOrder") {
updatedTasks.Add(sender.ID, sender);
}
if (IndentOrOutdent == "Upper")
updatedTasks.Add(sender.ID, sender);
//To update the server using timer, so that it will update the server only once when the task and depended tasks changed
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(function () {
if (controlClicked == null) {
if (adduprBlowRow == 'Y' || parentRowId != 0) {
$("#progress").css("display", "block");
adduprBlowRow = '';
SaveTaskonAddrowsChange(sender, parentRowId, args);
}
else {
if (updatedTasks.length > 0) {
$("#progress").css("display", "block");
UpdateTasks();
}
}
}
if (controlClicked != null) {
controlClicked = null;
updatedTasks = new RadiantQ.Gantt.Dictionary();
}
cacheRemovedTask(sender.ID);
addNewRow = "";
gantt.RedrawChartRows();
}.bind(this), 500);
}
}
My main aim to update that row with data and depended data in database on notifier. Is dere any disadvantage of using RebindPropertychange?
Please let me know if missing or doing some wrong code as some time it became very slow in rebind/load in gantt.
Plz provide me any best way to handle such cases like when perform any action suing context menu or gantt table edit update the same data only click once in databse.