BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
click(){This function is called on click event. After click I get gantt instance data and "Refresh row 1" in console but text in gantt stay same as before and it is not changed to "New text". After any other change e.q. inline edit at any line, it also change shown task name to "New text" on task with index 1.
let ganttObj = $("#gantt").ejGantt("instance");
console.log(ganttObj);
let item = ganttObj.model.updatedRecords[1];
item.taskName = "New text";
ganttObj.refreshRow(item.index);
console.log("Refresh row " + item.index);
}
click = function(){
let ganttObj = $("#GanttControl").ejGantt("instance");
let record = ganttObj.model.updatedRecords[1];
record.item.taskName = "New text"; // item of taskName mapping
ganttObj.updateRecordByTaskId(record.item);
} |
Hi,
thank you for your answer. Given example works grate on changing text, but it dosen't work on changing parent. I have Self Reference Gantt with [parentTaskIdMapping] ="parent" and when I change record.item.parent and then calling ganttObj.updateRecordByTaskId(record.item); it dosen't indent/outdent to right level.
Does exist any solution for that?
Marko
[Html]
<ej-gantt id="GanttControl
[allowDragAndDrop]=true
[dragTooltip.showTooltip]=true
[editSettings]="editsettings"
[toolbarSettings]="toolbar">
</ej-gantt>
[TS]
export class GanttComponent {
public childMapping: any;
public editsettings: any;
public toolbar: any;
constructor() {
this.editsettings = {
allowAdding: true,
allowEditing: true,
allowDeleting: true,
allowIndent:true,
editMode: 'cellEditing'
};
this.toolbar = {
showToolbar: true,
toolbarItems: ['add', 'edit', 'delete', 'update', 'cancel','indent','outdent', 'expandAll', 'collapseAll']
};
} |
Hi,
if I can not change task id with updateRecordByTaskId, is there any other way to change it?
I have to change it when I first time creating task in my DB. Curently is this on event actionComplete with requestType = save and it has any addedRecord and in my database is created new item with different id that gantt has genereted. So when I get response I would need to change this task id.
Or is there any better way to do all this?
In advence thank you for your answer,
Marko
[CS]
public ActionResult Index() {
var data = GetGanttdata();
}
public int GetCurrentIncValue()
{
int Id;
SqlConnection con = newSqlConnection(WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString);//connectionString
con.Open();
SqlCommand comm = new SqlCommand("SELECT IDENT_CURRENT ('GanttData1')", con);
Id = Convert.ToInt32(comm.ExecuteScalar());
con.Close();
return Id;
} |
function actionBegin(args) {
if (args.requestType == "beforeOpenAddDialog") {
var data = args.data, model = args.model,
ids = model.ids, taskName = "New Task";
var maxId = Id + 1;
data.TaskId = maxId;
data.TaskName = taskName + " " + maxId;
}
}
function actionComplete(args) {
if (args.requestType == "save" && args.addedRecord) {
var data = args.addedRecord.item;
$.ajax({
type: "POST",
url: '/Gantt/Add',
contentType: "application/json; charset=utf-8",
data: JSON.stringify(data),
dataType: "json",
success: function(data){
data.Id = ++Id;
}
});
}
}
|
Hi,
If I get auto_increment
value at the load time, this would not work when two or more users are adding tasks in Gantt, beacuse they would owerwrite each other tasks. I also can not async get AI number at actionBegin event beacuse in there I can not wait Obsorvable to complete. Also actionBegin is not called when in context menu is selected add new task > above / below
In my case I have one table in my DB for more Gantts, so even therefore this example would not work on multiple users and different Gantts at the same time.
Currently I create tasks with negative task Id, so first new get -1 then -2 etc. and on actionComplete request type=save I call my service to save task. Because ID is below zero service know that this is new task, therefore service save it to db and returns new task ID. At Angular side I subscribe to service and when I get response I set args.addedRecord.taskId and args.addedRecord.item.id to new ID. If i then call updateRecordByTaskId(args.addedRecord.item) it does not have effect on shown ID.
In Gantt then all works well, just negative task ID is shown (even after addedRecord.taskId and addedRecord.item.id is changed). But if I change some thing on new created task (for example some inline edit), then even shown ID is changed to corect value.
So is there any better way to do handel ID and suport multiple users? Is there any commodity condition where my solution would not work? (I know it would not work properly for predecessors if ID is chaning, but I think that betwen task created, task saved and task new task id setted is maximal 5 seconds and in this time no one can not create new connection)
I look forward to hearing from you,
Marko
Hi,
I have one more question about refreshing data in gantt.
ganttObj.updateRecordByTaskId(record.item); works well in most cases, but if I wantt with one click update more than 10 datas, this become slow.
So I wonder if there is also a way to update one column or if this is not possible, how to update whole shown gantt data without consequences on expand and collpse?
Regards,
Marko
<button id="columnUpdate" (click)="clickme($event)">Column Update</button>
<button id="updateData" (click)="clickme($event)">Update New Data</button>
clickme(e) {
var ganttObj = $("#GanttControl").ejGantt("instance"),
ganttModel = ganttObj.model;
var action = e.currentTarget.id;
switch (action) {
case "columnUpdate":
var ids = ganttModel.ids,
updatedRecords = ganttModel.updatedRecords;
for (var i = 0; i < this.columnData.length; i++) {
var index = -1,
newData = this.columnData[i];
index = ids.indexOf(newData[ganttModel.taskIdMapping].toString());
var temp = updatedRecords[index];
temp["taskName"] = temp.item[ganttModel.taskNameMapping] = newData[ganttModel.taskNameMapping];
ganttObj.refreshGanttRecord(temp);
}
break;
case "updateData":
ganttObj.setModel({ "dataSource": this.newGanttData });
break;
}
}; |