Send another parameter Create Task - Edit Task

Hello.
When i create a new task is called CreateTask function of the controller, after this is called EditTask with id ans taskdto parameters. I need to send another value to the EditTask.
I try to used the “return ok” to send another value, but the EditTask function doesn’t recive this value.
Example:

Return of CreateTask: return Ok(new
{
tid = id,
sid = sid,
action = “inserted”
});
Edit Function:
public IHttpActionResult EditTask(decimal id, TaskDto taskDto, decimal sid)

Is that possible?
Can you help me.
Thank you

Hello,
Unfortunately, I don’t specialize in ASP.NET technology, so I won’t be able to help you to modify the function on the server-side. But I can try to help you to apply some changes on the client-side.

1 Like

Thank you for your answer.
I will try to modify the function on the server-side by my self, but please tell me what changes i need to do on the client-side.
Thank you very much.

Hello,
When you use the gantt.createTask() feature, Gantt creates a temporary task and opens the lightbox. The changes aren’t sent to the server-side. If you close the lightbox by clicking on the “Cancel” and “Delete” buttons, the temporary task will be removed.

After you click on the “Save” button, Gantt creates a new task by merging the data from the temporary task with the values from the lightbox. After adding a task, the changes are sent on the server-side.

Please, describe what actually you need to do on the client-side.

Hello,
After i click on the “save” button, the CreateTask (server-side) function is called with parameters (TaskDto taskDto). When this function is end:

 return Ok(new
 {
       tid = newTask.ttaid,
       action = "inserted",
 });

After that, the EditTask (server-side) function is called with parameters (decimal id, TaskDto taskDto) and the taskDto is not updated with information add in CreateTask function.

I need to pass other parameter in editTask or update taskDto after called EditTask function.

I try to pass another parameter and prepare EditTask to received this parameter:

return Ok(new
{
    tid = newTask.ttaid,
    action = "inserted",
    sid = id2;
 });

but doesnt work, the function EditTask is not called after CreateTask.
When i call gantt.updateTask(client-side) with a new parameter, everything is find.

I try to pass a updated taskDto,

return Ok(new
{
    tid = newTask.ttaid,
    action = "inserted",
    taskDto = taskDto;
 });

but doesnt work because the EditTask receive a taskDto outdated and not my updated taskDto.

Where is edit is called? II think EditTask is called of client-side after return ok of server-side on insert a task

Please help me.
Thank you.

Hello,
Gantt doesn’t have the EditTask function:
https://docs.dhtmlx.com/gantt/api__refs__gantt_methods.html
A task can be modified via lightbox, inline editors, by dragging a task in the timeline or by API calls.
If you have a custom function, I need to see it.
If that function is part of the ASP.NET code - this is the server-side code, and I won’t be able to help you there.

As Gantt is a client-side application, you can only use the Data Processor’s API to modify what is sent to the server-side:
https://docs.dhtmlx.com/api__refs__dataprocessor.html
For example, you can use this event handler:
https://docs.dhtmlx.com/api__dataprocessor_onbeforeupdate_event.html

dp.attachEvent("onBeforeUpdate", function(id, state, data){
    data.sid = 'Your data';
    return true;
});

http://snippet.dhtmlx.com/04b45e1af

Another way is to use the built-in AJAX module to manually send the requests to the server-side:
https://docs.dhtmlx.com/gantt/api__gantt_ajax_other.html
http://snippet.dhtmlx.com/2e44ea051