PresetManager
Singleton
Intro
This is a global Store of ViewPresets, required to supply initial data to Scheduler's presets.
You can provide new view presets globally or for a specific scheduler.
NOTE: You cannot modify existing records in the PresetManager store. You can either remove preset records from the store or add new records to the store. Also please keep in mind, all changes provided to the PresetManager store are not reflected to the presets of schedulers that already exist!
If you want to have just a few presets (also known as zoom levels) in your Scheduler, you can slice corresponding records from the PresetManager and apply them to the Scheduler presets config.
const newPresets = PresetManager.records.slice(10, 12);
const scheduler = new Scheduler({
presets : newPresets, // Only 2 zoom levels are available
viewPreset : newPresets[0].id
});
If you want to adjust all default presets and assign to a specific scheduler you are going to create, you can extend them and pass as an array to the Scheduler presets config. Here is an example of how to set the same timeResolution to all ViewPresets.
const newPresets = PresetManager.map(preset => {
return {
id : 'my_' + preset.id,
base : preset.id, // Based on an existing preset
timeResolution : {
unit : 'day',
increment : 1
}
};
});
const scheduler = new Scheduler({
presets : newPresets,
viewPreset : 'my_hourAndDay'
});
If you want to do the same for all schedulers which will be created next, you can register new presets in a loop.
PresetManager.records.forEach(preset => {
// Pass the same ID, so when a new preset is added to the store,
// it will replace the current one.
PresetManager.registerPreset(preset.id, {
id : preset.id,
base : preset.id,
timeResolution : {
unit : 'day',
increment : 1
}
});
});
Here is an example of how to add a new ViewPreset to the global PresetManager store and to the already created scheduler presets.
const scheduler = new Scheduler({...});
const newGlobalPresets = PresetManager.add({
id : 'myNewPreset',
base : 'hourAndDay', // Based on an existing preset
columnLinesFor : 0,
// Override headers
headers : [
{
unit : 'day',
// Use different date format for top header 01.10.2020
dateFormat : 'DD.MM.YYYY'
},
{
unit : 'hour',
dateFormat : 'LT'
}
]
});
// Add new presets to the scheduler that has been created before changes
// to PresetManager are applied
scheduler.presets.add(newGlobalPresets);
Predefined presets
Predefined presets are:
secondAndMinute- creates a 2 level header - minutes and seconds:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6, 10, 0), endDate : new Date(2018, 4, 6, 10, 2), viewPreset : 'secondAndMinute', columns : [ { field : 'name', text : 'Name', width : 100 } ] });minuteAndHour- creates a 2 level header - hours and minutes:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6, 10), endDate : new Date(2018, 4, 6, 14), viewPreset : 'minuteAndHour', columns : [ { field : 'name', text : 'Name', width : 100 } ] });hourAndDay- creates a 2 level header - days and hours:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 10), viewPreset : 'hourAndDay', columns : [ { field : 'name', text : 'Name', width : 100 } ] });dayAndWeek- creates a 2 level header - weeks and days:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 20), viewPreset : 'dayAndWeek', columns : [ { field : 'name', text : 'Name', width : 100 } ] });dayAndMonth- creates a 2 level header - months and days:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 15), endDate : new Date(2018, 5, 14), viewPreset : 'dayAndMonth', columns : [ { field : 'name', text : 'Name', width : 100 } ] });weekAndDay- just likedayAndWeekbut with different formatting:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 20), viewPreset : 'weekAndDay', columns : [ { field : 'name', text : 'Name', width : 100 } ] });weekAndDayLetter- creates a 2 level header - weeks and day letters:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 6), endDate : new Date(2018, 4, 20), viewPreset : 'weekAndDayLetter', columns : [ { field : 'name', text : 'Name', width : 100 } ] });weekAndMonth- creates a 2 level header - months and weeks:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 15), endDate : new Date(2018, 5, 14), viewPreset : 'weekAndMonth', columns : [ { field : 'name', text : 'Name', width : 100 } ] });weekDateAndMonth- creates a 2 level header - months and weeks (weeks shown by first day only):const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 15), endDate : new Date(2018, 5, 14), viewPreset : 'weekDateAndMonth', columns : [ { field : 'name', text : 'Name', width : 100 } ] });monthAndYear- creates a 2 level header - years and months:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 4, 1), endDate : new Date(2018, 12, 31), viewPreset : 'monthAndYear', columns : [ { field : 'name', text : 'Name', width : 100 } ] });year- creates a 2 level header - years and quarters:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 0, 1), endDate : new Date(2019, 11, 31), viewPreset : 'year', columns : [ { field : 'name', text : 'Name', width : 100 } ] });manyYears- creates a 2 level header - 5-years and years:const scheduler = new Scheduler({ appendTo : targetElement, autoHeight : true, startDate : new Date(2018, 0, 1), endDate : new Date(2020, 11, 31), viewPreset : 'manyYears', columns : [ { field : 'name', text : 'Name', width : 100 } ] });
See the ViewPreset and ViewPresetHeaderRow classes for a description of the view preset properties.
Localizing View Presets
Bryntum Scheduler uses locales for translations including date formats for view presets.
To translate date format for view presets just define the date format for the specified region for your locale file, like this:
const locale = {
localeName : 'En',
// ... Other translations here ...
PresetManager : {
// Translation for the "weekAndDay" ViewPreset
weekAndDay : {
// Change the date format for the top and middle levels
topDateFormat : 'MMM',
middleDateFormat : 'D'
},
// Translation for the "dayAndWeek" ViewPreset
dayAndWeek : {
// Change the date format for the top level
topDateFormat : 'MMMM YYYY'
}
}
}
LocaleManager.applyLocale(locale);
Check the localization demo and this guide for more details.
See also
- ViewPreset - View preset configuration
- PresetStore - Preset store
- ViewPresetCombo - Combo for selecting presets
Note: Class is a singleton and all members listed below can be accessed as static ones.
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of StoreCRUD class, or subclass thereof.
-
Identifies an object as an instance of StoreChained class, or subclass thereof.
-
Identifies an object as an instance of StoreChanges class, or subclass thereof.
-
Identifies an object as an instance of StoreFilter class, or subclass thereof.
-
Identifies an object as an instance of StoreGroup class, or subclass thereof.
-
Identifies an object as an instance of StorePaging class, or subclass thereof.
-
Identifies an object as an instance of StoreRelation class, or subclass thereof.
-
Identifies an object as an instance of StoreSearch class, or subclass thereof.
-
Identifies an object as an instance of StoreSort class, or subclass thereof.
-
Identifies an object as an instance of StoreSparseIndex class, or subclass thereof.
-
Identifies an object as an instance of StoreState class, or subclass thereof.
-
Identifies an object as an instance of StoreStm class, or subclass thereof.
-
Identifies an object as an instance of StoreSum class, or subclass thereof.
-
Identifies an object as an instance of StoreSync class, or subclass thereof.
-
Identifies an object as an instance of StoreTree class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Get all registered stores
-
Store's unique identifier.
-
Returns the root store in the chain — the store that is not itself chained. For a store chained off another chained store, this walks up the full chain. Returns
thisif the store is not chained. -
Set to
falseto not record transaction duringapplyChangesetcall -
Is this a chained store?
-
Returns
trueif the data in this store depends on a remote data source. That is this Store is an AjaxStore, or uses requestData, or is chained off an AjaxStore. -
An empty array that can be used as a default value.
-
An empty object that can be used as a default value.
-
Identifies an object as an instance of PresetStore class, or subclass thereof.
-
Identifies an object as an instance of Store class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, so there is no need to test for both (for example,comp.isDestroying || comp.isDestroyed). -
Yields
trueif this Store is loaded page by page. See the remotePaging config. -
If the store is paged, yields the highest page number in the dataset as calculated from the 'total' returned in the last page data block loaded.
-
Returns all locally available records from the store, ignoring any filters and including grouping headers / footers.
-
Setting
autoCommittotrueautomatically commits changes to records. -
Get the first record locally available in the store.
-
Get the last record locally available in the store.
-
Class used to represent records. Defaults to class Model.
-
Returns all locally available "visible" records. Note: The returned value may not be mutated!
-
Yields the complete dataset size, ignoring filtering and grouping. If the store is paged, it returns the
totalvalue provided in the page load request response, or manually set. -
Currently applied filters. A collection of CollectionFilter instances.
-
Currently used groupers. To set groupers when remote sorting is enabled by sortParamName you should use setGroupers instead to be able to wait for the operation to finish.
-
Check if store is filtered
-
Is store currently grouped?
-
Is store sorted?
-
Currently applied sorters
-
Pretty printed version of json
-
Returns all the group header records
-
If the store is paged, yields the current page number.
-
The sorter function for sorting records in the store.
-
trueif this Store is configured to handle tree data (withtree : true) or if this is a chained store and the master store is a tree store. -
Returns all leaf records in a tree store
-
The invisible root node of this tree.
Functions
Functions are methods available for calling on the class-
This optional class method is called when a class is mixed in using the mixin() method.
-
Registers this class type with its Factory
-
Clears store data. Used by removeAll, separate function for using with chained stores.
-
Updates records available in a chained store by filtering the master store records using chainedFilterFn
-
Internal function used to hook destroy() calls when using thisObj
-
Internal function used restore hooked destroy() calls when using thisObj
-
Auto detaches listeners registered from start, if set as detachable
-
Internal function used to run a callback function after an event is triggered
-
Removes all listeners registered to this object by the application.
-
Resumes automatic commits upon store changes. Will trigger commit if the internal counter is 0.
-
Suspends automatic commits upon store changes. Can be called multiple times (it uses an internal counter).
-
Accepts all changes, resets the modification tracking:
- Clears change tracking for all records
- Clears added
- Clears modified
- Clears removed Leaves the store in an "unmodified" state.
-
Handles changes in master stores data. Updates the chained store accordingly
-
Handles refresh events from the master store. During batch operations, individual change events are suppressed and only a refresh event with
action: 'batch'fires afterendBatch(). This ensures the chained store stays in sync after batch operations. -
Relays some function calls to the master store
-
Initialized relations, called from constructor
-
Updates relationCache for all records.
-
Sets a collection of related records. Will updated the related store and trigger events from it. Not to be called directly, called from Model setter.
-
Updates relation cache and foreign key value when a related objects id is changed.
Events
Events are triggered for certain actions in this class and can be listened for to react to those actions in your code-
Fired when one of this Store's constituent records is modified while in batched state. This may be used to keep UIs up to date while "tentative" changes are made to a record which must not be synced with a server.
Event handlers
Event handlers are callbacks called as a result of certain actions in this class-
Called when one of this Store's constituent records is modified while in batched state. This may be used to keep UIs up to date while "tentative" changes are made to a record which must not be synced with a server.