Show cool things you have done with our products


Post by rdonahue6 »

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?

Post by arcady »

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).

Post by rdonahue6 »

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;
}
Attachments
Task_Structure_With_Initial_Load.PNG
Task_Structure_With_Initial_Load.PNG (17.11 KiB) Viewed 8627 times

Post by arcady »

Ok, it's almost ready.. Now please made a runnable test case out of this. :)
It's easy. Just pick some of our examples that use CrudManager ("advanced" for example) and put this code changes and data into it. So we could open your example in a browser and debug.

Post by rdonahue6 »

I didn't get exactly what you want me to provide. I think I have shared with you enough to chip in my code changes with the data I have provided in your sample example (Advance one) to debug.

Post by arcady »

We need a proper runnable test case to assist you.
https://forum.bryntum.com/viewtopic.php?f=35&t=772

Post by rdonahue6 »

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.
Attachments
Sample Test Case.zip
(1.86 KiB) Downloaded 307 times

Post by rdonahue6 »

Hi,

Is there anything you want further.
I am waiting for your sincere response..

Post by arcady »

It raises exception for me on this line:
        	Gnt.examples.advanced.crud.CrudManager.sync(); 
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:
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)
Have you checked that the test case actually reproduces the problem before sending it to us?

Post by rdonahue6 »

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).

Post Reply