createDatastore

creates a datastore according to the provided configuration

datastore & treedatastore createDatastore(DatastoreConfig config);
configDatastoreConfiga configuration object of a datastore
datastore & treedatastorethe datastore or treedatastore object depending on the type

Example

var resourcesStore = gantt.createDatastore({
    name:"resource",
    initItem: function(item){
        item.id = item.key || gantt.uid();
        return item;
    }
});

Related samples

Details

Configuration object properties:

  • name - (string) - an arbitrary string name of the datastore. The datastore can be accessed by its name using getDatastore.
  • initItem? (item): any - optional, preprocesses items loaded into the datastore. It is a good place to set the default values of the datastore items. The function takes the following parameter:
    • item - (any) - the resource item.
  • type? - (string) - optional, accepts only one fixed value "treeDatastore". If the type:"treeDatastore" is specified, the datastore will support hierarchical data, with the id property as a primary key, and parent as a link to the parent id. Any other value will produce a flat list datastore.
  • fetchTasks? - (boolean) - optional, enables showing all tasks assigned to a certain resource in the resource view panel. This functionality works both for the resource diagram and resource histogram types of layout.
See also
Back to top