I have an resource assignment column on my Gantt. I can change the assignments but I want to know how to save them ? Also can I change the assignment default unit of percentage tot hours.
How to save resource assignments on Bryntum's Gantt?
2k views Asked by Mukta Chourishi At
1
Read up a little bit on the CrudManager that deals with data loading and saving. This link has all you need.
http://www.bryntum.com/docs/scheduling/3.x/?#!/guide/gantt_crud_manager
Introduction
This guide describes how to use the CRUD manager with Ext Gantt. It contains only Gantt specific details. For general information on CRUD manager implementation and architecture see this guide.
The class implementing CRUD manager for Ext Gantt is called Gnt.data.CrudManager. It uses AJAX as transport system and JSON as encoding format. Benefits of using the CRUD manager
In previous versions of the Ext Gantt, you had to load and save data using the standard Ext JS data package. This would involve setting proxies on data stores and handling load and save on each such store. This approach worked, but had a few drawbacks:
For performance reasons, obvisously we'd like the loading process to use a single request that returns the data to be consumed by all the stores used in the Gantt chart. This is now easy to achieve since the CM loads the data in one request. When it comes to saving changes, you normally want to have an "all-or-nothing" transaction-based approach to persisting updates in your database. This is not feasible if you're using two separate ajax requests. Stores
There are a number of different data entities used in Ext Gantt: calendars, resources, assignments, dependencies and tasks. To register them with a Gnt.data.CrudManager instance, the following configs should be used respectively: calendarManager, resourceStore, assignmentStore, dependencyStore, taskStore.
Here's a how a basic configuration would look:
The backend, in this case the "read.php" should return a JSON similar to the one seen below:
You should not specify calendarManager, resourceStore, dependencyStore and assignmentStore configs if they were already specified for the task store instance. In this case, the CRUD manager will just take them from the provided task store instance:
You can provide any number of additional stores using the stores config:
var crudManager = new Gnt.data.CrudManager({ taskStore : taskStore, stores : [ store1, store2, store3 ], transport : { load : { url : 'php/read.php' }, sync : { url : 'php/save.php' } } });
Or add them programmatically using the addStore method:
Implementation
Here is how a CRUD manager can be created:
In above example data, the load operation will start automatically since the CM is configured with the autoLoad option set to true. There is also a load method to invoke loading manually:
To persist changes automatically, there is an autoSync option, and you can of course also call the sync method manually if needed:
Any Gnt.panel.Gantt instances can be configured to use a CRUD manager by providing the crudManager config. In this case you don't need to specify taskStore, dependencyStore, resourceStore, assignmentStore on the Gantt panel. They will be taken from provided crudManager instance.
Calendars
Gnt.data.CrudManager supports bulk loading of all the project calendars in a project. To be able to do this, the Gnt.data.CrudManager.calendarManager config has to be specified or it can be specified on the task store.
Load response structure
The calendar manager load response has a bit more complex structure than the described general one.
The first difference from a standard response is that for each calendar we include its data under the Days field. The object under Days field has exactly the same structure as any other object containing store data. It has rows containing an array of calendar records (each represents a Gnt.model.CalendarDay instance) and total defines the number of them.
Another thing to take a note on, is how metaData is used for calendar manager loading. It has a projectCalendar property which must contain the identifier of the calendar that should be used as the project calendar.