v7.3.0
SupportExamplesFree Trial

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 like dayAndWeek but 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

Note: Class is a singleton and all members listed below can be accessed as static ones.

No results

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isStoreCRUD : Booleantrue
    READONLY
    static
    ADVANCED
    StoreCRUD
    Identifies an object as an instance of StoreCRUD class, or subclass thereof.
  • isStoreChained : Booleantrue
    READONLY
    static
    ADVANCED
    StoreChained
    Identifies an object as an instance of StoreChained class, or subclass thereof.
  • isStoreChanges : Booleantrue
    READONLY
    static
    ADVANCED
    StoreChanges
    Identifies an object as an instance of StoreChanges class, or subclass thereof.
  • isStoreFilter : Booleantrue
    READONLY
    static
    ADVANCED
    StoreFilter
    Identifies an object as an instance of StoreFilter class, or subclass thereof.
  • isStoreGroup : Booleantrue
    READONLY
    static
    ADVANCED
    StoreGroup
    Identifies an object as an instance of StoreGroup class, or subclass thereof.
  • isStorePaging : Booleantrue
    READONLY
    static
    ADVANCED
    StorePaging
    Identifies an object as an instance of StorePaging class, or subclass thereof.
  • isStoreRelation : Booleantrue
    READONLY
    static
    ADVANCED
    StoreRelation
    Identifies an object as an instance of StoreRelation class, or subclass thereof.
  • isStoreSearch : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSearch
    Identifies an object as an instance of StoreSearch class, or subclass thereof.
  • isStoreSort : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSort
    Identifies an object as an instance of StoreSort class, or subclass thereof.
  • isStoreSparseIndex : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSparseIndex
    Identifies an object as an instance of StoreSparseIndex class, or subclass thereof.
  • isStoreState : Booleantrue
    READONLY
    static
    ADVANCED
    StoreState
    Identifies an object as an instance of StoreState class, or subclass thereof.
  • isStoreStm : Booleantrue
    READONLY
    static
    ADVANCED
    StoreStm
    Identifies an object as an instance of StoreStm class, or subclass thereof.
  • isStoreSum : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSum
    Identifies an object as an instance of StoreSum class, or subclass thereof.
  • isStoreSync : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSync
    Identifies an object as an instance of StoreSync class, or subclass thereof.
  • isStoreTree : Booleantrue
    READONLY
    static
    ADVANCED
    StoreTree
    Identifies an object as an instance of StoreTree class, or subclass thereof.
  • properties : Object
    internal
    static
    Store

    A class property getter for the default values of internal properties for this class.

  • stores : Store[]
    READONLY
    static
    Store

    Get all registered stores

  • id : String/Number
    READONLY
    Store

    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 this if the store is not chained.

  • Set to false to not record transaction during applyChangeset call

  • isChained : Boolean
    READONLY
    NON-LAZY-LOAD
    StoreChained

    Is this a chained store?

  • Returns true if 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.

  • emptyArray : Array
    internal
    READONLY
    Store

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    Store

    An empty object that can be used as a default value.

  • isPresetStore : Booleantrue
    READONLY
    ADVANCED
    PresetStore
    Identifies an object as an instance of PresetStore class, or subclass thereof.
  • isStore : Booleantrue
    READONLY
    ADVANCED
    Store
    Identifies an object as an instance of Store class, or subclass thereof.
  • config : Object
    READONLY
    ADVANCED
    Store

    Returns a copy of the full configuration which was used to configure this object.

  • isConstructing : Boolean
    READONLY
    ADVANCED
    Store

    This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    Store

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • isPaged : Boolean
    READONLY
    NON-LAZY-LOAD
    StorePaging

    Yields true if this Store is loaded page by page. See the remotePaging config.

  • lastPage : Number
    READONLY
    NON-LAZY-LOAD
    StorePaging

    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 autoCommit to true automatically commits changes to records.

  • first : Model
    READONLY
    Store

    Get the first record locally available in the store.

  • Boolean flag, indicating whether the store has any data changes (its changes accessor returns a non-empty object). Cheaper than changes accessor itself, because it does not clone some internal data structures.

  • last : Model
    READONLY
    Store

    Get the last record locally available in the store.

  • Class used to represent records. Defaults to class Model.

  • records : Model[]
    READONLY
    IMMUTABLE
    Store

    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 total value 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

  • groupHeaderRecords : Model[]
    READONLY
    NON-LAZY-LOAD
    StoreGroup

    Returns all the group header records

  • If the store is paged, yields the current page number.

  • sorterFn : Function
    internal
    READONLY
    StoreSort

    The sorter function for sorting records in the store.

  • true if this Store is configured to handle tree data (with tree : true) or if this is a chained store and the master store is a tree store.

  • Returns all leaf records in a tree store

  • rootNode : Model
    READONLY
    Store

    The invisible root node of this tree.

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    Store

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    Store

    Registers this class type with its Factory

  • clear( )
    private
    StoreCRUD

    Clears store data. Used by removeAll, separate function for using with chained stores.

  • Reverts all changes in the store (adds removed records back, and removes newly added records).


    Triggers: change, refresh

  • fillFromMaster( )
    NON-LAZY-LOAD
    StoreChained

    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

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

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

  • Perform sorting according to the sorters configured. This is the internal implementation which is overridden in AjaxStore and must not be overridden.

  • 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 after endBatch(). This ensures the chained store stays in sync after batch operations.

  • Relays some function calls to the master store

  • Perform filtering according to the filters Collection. This is the internal implementation which is overridden in AjaxStore and must not be overridden.

  • 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