I want to remove/delete task using CrudManager sync.
With context menu "Delete Tasks", I am calling CrudManager.sync() once task is deleted from the store by it's default behavior i.e. using this.deteleTask()
Request from client :
{"type":"sync","requestId":1481053856034,"tasks":{"removed":[{"Id":"34020.42219.56680.6492"}]}}
Response from server :
{'success' : true,'tasks' : { 'rows' : [ ], 'removed' : [{'Id':'34020.42219.56680.6492'}] }, 'dependencies' : { 'rows' : [], }}
Once delete operation is over and synced, on any further update operation (e.g. using cell edit) when I invoke CrudManager.sync(), along with updated task info I am getting removed task info (which should not come) with request from client.
Similarly after delete task operation is over, if I invoke CrudManager.reject(), deleted task re-appears in the grid at some different position than it was before delete.
As per below document, I believe my request-response content are inline.
https://www.bryntum.com/products/gantt-for-extjs/docs/ ... ud_manager
Once task deleted and synced/saved, it should not be available in the store, which is not happening for me.
Any help on this if I am doing anything wrong with my request-response content or with the flow would be greatly appreciated?
Support Forum
It's hard to say without seeing the code. We need a proper runnable test case to assist you.
Please provide a sample load and sync responses (in static files like we do in our examples).
Also provide textual instructions which task to delete before invoking sync request (to match the sync response in the static file).
Please provide a sample load and sync responses (in static files like we do in our examples).
Also provide textual instructions which task to delete before invoking sync request (to match the sync response in the static file).
Hi arcady,
Thanks for the quick response. Your expected details are as below.
Here I have taken 3 tasks in my Project (Please refer the attachment)
My load response:
{'success' : true,'tasks' : { 'rows' : [ {'Name': 'GanttTest','EnglishType': 'ProjectSpace','Assignee': '','Id': '34020.42219.54816.8065','expanded': true,'Type': 'Project\x20Space','TaskSequenceId': 0,'Dependency': '','State': 'Ready','PercentComplete': 0.0,'EstimatedDuration': '3.0\x20Days','Duration': 3.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 7, 2016','Policy': 'Project\x20Space','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-08','leaf': false,'children': [{'Name': 'Task1','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.16144.23116','expanded': false,'Type': 'Task','TaskSequenceId': 1,'Dependency': '','State': 'Ready','PercentComplete': 0.0,'EstimatedDuration': '2.0\x20Days','Duration': 2.0,'DisplayStartDate': 'Nov 4, 2016','DisplayFinishDate': 'Nov 7, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D23\x20Days','StartDate': '2016-11-04','EndDate': '2016-11-08','leaf': true},{'Name': 'Task2','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.35704.48464','expanded': false,'Type': 'Task','TaskSequenceId': 2,'Dependency': '','State': 'Preliminary','PercentComplete': 0.0,'EstimatedDuration': '1.0\x20Days','Duration': 1.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 3, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-04','leaf': true},{'Name': 'Task3','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.43004.27184','expanded': false,'Type': 'Task','TaskSequenceId': 3,'Dependency': '','State': 'Preliminary','PercentComplete': 0.0,'EstimatedDuration': '1.0\x20Days','Duration': 1.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 3, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-04','leaf': true}]} ]}, 'dependencies' : { 'rows' : [] }}
Now I want to delete 2nd task that is Task2 (as in attachment) from the Project.
Sync request from client :
{"type":"sync","requestId":1481124047961,"tasks":{"removed":[{"Id":"34020.42219.35704.48464"}]}}
Sync response from server :
{revision : 124, 'success' : true,'tasks' : { 'rows' : [ ], 'removed' : [{'Id':'34020.42219.35704.48464'}] }, 'dependencies' : { 'rows' : [], }}
Code snippet for Menu creation with handler:
var taskContextMenuPlugin = Ext.create('Gnt.plugin.TaskContextMenu', {
createMenuItems : function () {
return [
{
handler : this.deleteTasksHandler,
requiresTask : true,
itemId : 'deleteTask',
text : this.L('deleteTask')
},
;
},
addTaskAboveHandler : function () {
this..deleteTask();
var crudManager = App.Gantt.gantt.getCrudManager();//This is how we obtain instance of CM
crudManager.sync();
},
});
return taskContextMenuPlugin;
}
Thanks for the quick response. Your expected details are as below.
Here I have taken 3 tasks in my Project (Please refer the attachment)
My load response:
{'success' : true,'tasks' : { 'rows' : [ {'Name': 'GanttTest','EnglishType': 'ProjectSpace','Assignee': '','Id': '34020.42219.54816.8065','expanded': true,'Type': 'Project\x20Space','TaskSequenceId': 0,'Dependency': '','State': 'Ready','PercentComplete': 0.0,'EstimatedDuration': '3.0\x20Days','Duration': 3.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 7, 2016','Policy': 'Project\x20Space','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-08','leaf': false,'children': [{'Name': 'Task1','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.16144.23116','expanded': false,'Type': 'Task','TaskSequenceId': 1,'Dependency': '','State': 'Ready','PercentComplete': 0.0,'EstimatedDuration': '2.0\x20Days','Duration': 2.0,'DisplayStartDate': 'Nov 4, 2016','DisplayFinishDate': 'Nov 7, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D23\x20Days','StartDate': '2016-11-04','EndDate': '2016-11-08','leaf': true},{'Name': 'Task2','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.35704.48464','expanded': false,'Type': 'Task','TaskSequenceId': 2,'Dependency': '','State': 'Preliminary','PercentComplete': 0.0,'EstimatedDuration': '1.0\x20Days','Duration': 1.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 3, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-04','leaf': true},{'Name': 'Task3','EnglishType': 'FALSE','Assignee': '','Id': '34020.42219.43004.27184','expanded': false,'Type': 'Task','TaskSequenceId': 3,'Dependency': '','State': 'Preliminary','PercentComplete': 0.0,'EstimatedDuration': '1.0\x20Days','Duration': 1.0,'DisplayStartDate': 'Nov 3, 2016','DisplayFinishDate': 'Nov 3, 2016','Policy': 'Project\x20Task','Unit': '\x20Days','DurationUnit': 'd','Deviation': '\x2D24\x20Days','StartDate': '2016-11-03','EndDate': '2016-11-04','leaf': true}]} ]}, 'dependencies' : { 'rows' : [] }}
Now I want to delete 2nd task that is Task2 (as in attachment) from the Project.
Sync request from client :
{"type":"sync","requestId":1481124047961,"tasks":{"removed":[{"Id":"34020.42219.35704.48464"}]}}
Sync response from server :
{revision : 124, 'success' : true,'tasks' : { 'rows' : [ ], 'removed' : [{'Id':'34020.42219.35704.48464'}] }, 'dependencies' : { 'rows' : [], }}
Code snippet for Menu creation with handler:
var taskContextMenuPlugin = Ext.create('Gnt.plugin.TaskContextMenu', {
createMenuItems : function () {
return [
{
handler : this.deleteTasksHandler,
requiresTask : true,
itemId : 'deleteTask',
text : this.L('deleteTask')
},
;
},
addTaskAboveHandler : function () {
this..deleteTask();
var crudManager = App.Gantt.gantt.getCrudManager();//This is how we obtain instance of CM
crudManager.sync();
},
});
return taskContextMenuPlugin;
}
- Attachments
-
- Task_Structure_With_Initial_Load.PNG (17.11 KiB) Viewed 8671 times
We need a proper runnable test case to assist you.
https://forum.bryntum.com/viewtopic.php?f=35&t=772
https://forum.bryntum.com/viewtopic.php?f=35&t=772
Here you go.
Please find the attachment with sample test case to run and debug. Let me know in case you need anything further.
Thanks.
Please find the attachment with sample test case to run and debug. Let me know in case you need anything further.
Thanks.
- Attachments
-
- Sample Test Case.zip
- (1.86 KiB) Downloaded 314 times
It raises exception for me on this line:
The Gnt.examples.advanced.crud.CrudManager is a class name. You should call the method in an instance context.
Anyway ..you could have simply added "autoSync : true" to the class if you wanted it to sync after removal, that's what I did. And I could not reproduce the issue you describe w/ the code you posted:
Have you checked that the test case actually reproduces the problem before sending it to us?
Gnt.examples.advanced.crud.CrudManager.sync();
Anyway ..you could have simply added "autoSync : true" to the class if you wanted it to sync after removal, that's what I did. And I could not reproduce the issue you describe w/ the code you posted:
Ext.ComponentQuery.query('ganttpanel')[0].crudManager.getTaskStore().getRemovedRecords()
[]
// no removed records left in the task store after sync
Ext.ComponentQuery.query('ganttpanel')[0].crudManager.getTaskStore().each(function (task) { console.log(task.getId()); });
100
101
103
// 3 records left in the task store after sync (4 initially loaded minus 1 removed)
Thanks arcady.
Actually we don't do autoSync. For cell edit operation we make changes and sync using some save button. For add/remove task we are manually calling sync() upon crudmanager instance.
For add task, sync is working fine. But for delete task I am have this problem with sync.
Though I am not getting any error on sync, crudmanager seems not getting updated with my sync response when I delete task(s).
Actually we don't do autoSync. For cell edit operation we make changes and sync using some save button. For add/remove task we are manually calling sync() upon crudmanager instance.
For add task, sync is working fine. But for delete task I am have this problem with sync.
Though I am not getting any error on sync, crudmanager seems not getting updated with my sync response when I delete task(s).