v7.3.0

GridBase
Widget

A thin base class for Grid. Does not include any features by default, allowing smaller custom-built bundles if used in place of Grid. Use GridBase when you want to minimize bundle size and only include the specific features you need.

NOTE: In most scenarios you probably want to use Grid instead of GridBase.

import GridBase from 'lib/Grid/view/GridBase.js';
import Sort from 'lib/Grid/feature/Sort.js';

const grid = new GridBase({ appendTo : document.body, features : { sort : true // Only this feature is included in the bundle }, columns : [ { field : 'name', text : 'Name' } ], data : [ { name : 'Dan' }, { name : 'Steve' } ] });

Useful configs and functions

Member Description
columns Array of column definitions
store Data store supplying rows
data Inline data array (creates a store automatically)
features Object to enable/configure grid features
subGridConfigs Configure the locked/normal grid sections
rowHeight Height of each row in pixels
scrollRowIntoView Scrolls a row into the visible area
getCell Returns cell element for a record and column

See also

  • Grid - Full-featured grid with default features included
  • TreeGrid - Tree variant of the grid
  • Column - Base column class
  • Store - Data store for grid rows
No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • An object containing Feature configuration objects (or true if no configuration is required) keyed by the Feature class name in all lowercase.

  • See Keyboard shortcuts for details

  • Preserve the grid's vertical scroll position when changesets are applied, as in the case of remote changes, or when stores are configured with syncDataOnLoad.

    Has a corresponding runtime preserveScroll property.

  • Configure UI transitions for various actions in the grid.

    • insertRecord : Boolean

      Transition record insertions

    • removeRecord : Boolean

      Transition record removals

    • toggleColumn : Boolean

      Transition column visibility changes

    • expandCollapseColumn : Boolean

      Transition parent/group column expand/collapse

    • toggleRegion : Boolean

      Transition region expand/collapse

    • toggleTreeNode : Boolean

      Transition tree node expand/collapse

    • toggleGroup : Boolean

      Transition group expand/collapse

    • filterRemoval : Booleanfalse

      Transition row removals caused by filtering (under specific conditions)

    Has a corresponding runtime transition property.

  • Automatically set grids height to fit all rows (no scrolling in the grid). In general you should avoid using autoHeight: true, since it will bypass Grids virtual rendering and render all rows at once, which in a larger grid is really bad for performance.

  • Set to true to stretch the last column in a grid with all fixed width columns to fill extra available space if the grid's width is wider than the sum of all configured column widths.

  • Set to false to only measure cell contents when double-clicking the edge between column headers.

  • animateFilterRemovals : Booleanfalse
    DEPRECATED
    Deprecated:

    7.0.0 Deprecated animateFilterRemovals. Use transition.filterRemoval instead

    Set to true to animate row removals caused by filtering.

  • Deprecated:

    7.0.0 Deprecated animateRemovingRows. Use transition.removeRecord instead

    Controls if removing and inserting rows should be animated. Set to false to prevent those animations, removing the related delays.

  • Set to false to crop text in grid cells without ellipsis (...). When enabled, cells containing pure use display : block, instead of display : flex to allow ellipsis to work. NOTE Only supported in browsers that support :has() CSS selector

    Has a corresponding runtime cellEllipsis property.

  • Set to false to not show column lines. End result might be overruled by/differ between themes.

    Has a corresponding runtime columnLines property.

  • contextMenuTriggerEvent : 'contextmenu'/'click'/'dblclick'contextmenu

    Event which is used to show context menus. Available options are: 'contextmenu', 'click', 'dblclick'.

  • Region to which columns are added when they have none specified

  • Set to true to destroy the store when the grid is destroyed.

  • Set to true to not get a warning when using another base class than GridRowModel for your grid data. If you do, and would like to use the full feature set of the grid then include the fields from GridRowModel in your model definition.

  • enableSticky : Boolean
    DEPRECATED
    Deprecated:

    7.3.0 Use features : { stickyCells : true } instead

    Set to true to enable the StickyCells feature, which pins cell content to the top of the grid while rows scroll off the top but remain visible.

  • Set to true to hide the footer elements

    Has a corresponding runtime hideFooters property.

  • Set to true to hide the column header elements

    Has a corresponding runtime hideHeaders property.

  • Set to true to hide the Grid's horizontal scrollbar(s)

  • Grids change the maskDefaults to cover only their body element.

  • Grid monitors window resize by default.

  • True to preserve focused cell after loading new data

  • Specify true to preserve vertical scroll position after store actions that trigger a refresh event, such as loading new data and filtering.

  • Set to false to not show row lines. End result might be overruled by/differ between themes.

    Has a corresponding runtime rowLines property.

  • Animation transition duration in milliseconds.

    Has a corresponding runtime transitionDuration property.

  • Configuration values for the ScrollManager class on initialization. Returns the ScrollManager at runtime.

    Has a corresponding runtime scrollManager property.

  • The class to instantiate to use as the scrollable. Defaults to Scroller.

  • Set to true to allow text selection in the grid cells. Note, this cannot be used simultaneously with the RowReorder feature.

  • Set to true to not get a warning when calling getState when there is a column configured without an id. But the recommended action is to always configure columns with an id when using states.

  • animateTreeNodeToggle : Booleantrue
    DEPRECATED
    Deprecated:

    7.0.0 Deprecated animateTreeNodeToggle. Use transition.toggleTreeNode instead

    When the Tree feature is in use and the Store is a tree store, this config may be set to true to visually animate branch node expand and collapse operations.

    This is not supported in Scheduler and Gantt

    Has a corresponding runtime animateTreeNodeToggle property.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isGridBase : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of GridBase class, or subclass thereof.
  • Preserve the grid's vertical scroll position when changesets are applied, as in the case of remote changes, or when stores are configured with syncDataOnLoad.

    Has a corresponding preserveScroll config.

  • contentHeight : Number
    private
    READONLY

    Returns content height calculated from row manager

  • isGridBase : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of GridBase class, or subclass thereof.
  • bodyHeight : Number
    READONLY

    Body height

  • footerHeight : Number
    READONLY

    Footer height

  • headerHeight : Number
    READONLY

    Header height

  • Set to false to crop text in grid cells without ellipsis (...). When enabled, cells containing pure use display : block, instead of display : flex to allow ellipsis to work. NOTE Only supported in browsers that support :has() CSS selector

    Has a corresponding cellEllipsis config.

  • Set to false to not show column lines. End result might be overruled by/differ between themes.

    Has a corresponding columnLines config.

  • Set to true to hide the footer elements

    Has a corresponding hideFooters config.

  • Set to true to hide the column header elements

    Has a corresponding hideHeaders config.

  • Set to false to not show row lines. End result might be overruled by/differ between themes.

    Has a corresponding rowLines config.

  • Animation transition duration in milliseconds.

    Has a corresponding transitionDuration config.

  • bottomRow : Row
    private
    READONLY

    Get the Row currently displayed furthest down.

  • firstVisibleRow : Row
    READONLY

    Get the topmost visible grid row

  • lastVisibleRow : Row
    READONLY

    Get the last visible grid row

  • topRow : Row
    private
    READONLY

    Get the Row that is currently displayed at top.

  • Configuration values for the ScrollManager class on initialization. Returns the ScrollManager at runtime.

    Has a corresponding scrollManager config.

  • animateTreeNodeToggle : Booleantrue
    DEPRECATED
    Deprecated:

    7.0.0 Deprecated animateTreeNodeToggle. Use transition.toggleTreeNode instead

    When the Tree feature is in use and the Store is a tree store, this config may be set to true to visually animate branch node expand and collapse operations.

    This is not supported in Scheduler and Gantt

    Has a corresponding animateTreeNodeToggle config.

Functions

Functions are methods available for calling on the class
    • Remember scroll position when store is about to apply a changeset

    • doDestroy( )
      private

      Cleanup

    • measureRowHeight( )
      private

      Creates a fake subgrid with one row and measures its height. Result is used as rowHeight.

    • onThemeChange( )
      private

      Handler for global theme change event (triggered by shared.js). Remeasures row height.

    • Recalculates virtual scrollbars widths and scrollWidth

    • Restore scroll position. Go to the topmost row formerly in the view that is still present in the dataset.

    • setGridClassList( )
      private

      Adds extra classes to the Grid element after it's been configured. Also iterates through features, thus ensuring they have been initialized.

    • Resumes CSS transitions after a row / event has been updated

    • Hide the load mask.

    • Rerenders all grid headers

    • Rerenders the grids rows, headers and footers, completely replacing all row elements with new ones

    • Rerenders all grid rows, completely replacing all row elements with new ones

    • initScroll( )
      private

      Scroll syncing for normal headers & grid + triggers virtual rendering for vertical scroll


      Triggers: scroll

    • bindStore( )
      private

      Hooks up data store listeners

    • onStoreAdd( )
      private

      Refreshes rows when data is added to the store

    • Hides load mask after a load request ends either in success or failure

    • Shows a load mask while the connected store is loading

    • onStoreDataChange( )
      private

      Refreshes rows when data is changed in the store

    • onStoreException( )
      private

      Responds to exceptions signalled by the store

    • The hook is called when the id of a record has changed.

    • onStoreRemove( )
      private

      Animates removal of record.

    • onStoreRemoveAll( )
      private

      Rerenders grid when all records have been removed

    • Rerenders a cell if a record is updated in the store

    • fixSizes( )
      private

      Sets widths and heights for headers, rows and other parts of the grid as needed

    • collapseAll( )
      FROM-FEATURE
      NON-LAZY-LOAD

      Collapse all groups. This function is exposed on Grid and can thus be called as grid.collapseAll()

      Added by the Group feature, only available when that feature is enabled.

    • expandAll( )
      FROM-FEATURE
      NON-LAZY-LOAD

      Expand all groups. This function is exposed on Grid and can thus be called as grid.expandAll()

      Added by the Group feature, only available when that feature is enabled.

    • refreshGroups( )
      private
      FROM-FEATURE
      NON-LAZY-LOAD

      Refreshes the store tree grouping by re-applying the current transformation.

      // Refresh groups
      grid.refreshGroups();
      

      Added by the TreeGroup feature, only available when that feature is enabled.

    Events

    Events are triggered for certain actions in this class and can be listened for to react to those actions in your code
    • fillHandleDragAbort
      FROM-FEATURE

      Fired when a FillHandle drag operation is aborted.

      Added by the FillHandle feature, only available when that feature is enabled.

    • unsplit
      FROM-FEATURE

      Fires when un-splitting the Grid.

      Added by the Split feature, only available when that feature is enabled.

    Event handlers

    Event handlers are callbacks called as a result of certain actions in this class
    • onFillHandleDragAbort
      FROM-FEATURE

      Called when a FillHandle drag operation is aborted.

      Added by the FillHandle feature, only available when that feature is enabled.

    • onUnsplit
      FROM-FEATURE

      Called when un-splitting the Grid.

      Added by the Split feature, only available when that feature is enabled.

    Type definitions

    CSS variables

    CSS variables that can be set to adjust appearance
    Name Description
    --b-grid-background Grid background color
    --b-grid-cell-background Grid cell background
    --b-grid-cell-border-color Grid cell border color
    --b-grid-cell-border-width Grid cell border width. By default also applies to headers
    --b-grid-cell-color Grid cell color
    --b-grid-cell-dirty-color Grid cell dirty indicator color
    --b-grid-cell-font-size Grid cell font size
    --b-grid-cell-font-weight Grid cell font weight
    --b-grid-cell-gap Grid cell inner gap
    --b-grid-cell-highlight-color Background color for highlighted cells in color mode
    --b-grid-cell-padding-block Grid cell padding block. Defaults to 0, since cells are sized programmatically and content is centered vertically
    --b-grid-cell-padding-inline Grid cell padding inline. By default also applies to headers
    --b-grid-column-transition-duration Transition duration for column operations such as showing, hiding and collapsing
    --b-grid-empty-color Text color for the message shown when the grid is empty
    --b-grid-empty-padding Padding for the message shown when the grid is empty
    --b-grid-panel-header-border-bottom Bottom border for the grid panel header (when having a title or panel tools)
    --b-grid-panel-header-padding Padding for the grid panel header (when having a title or panel tools)
    --b-grid-row-border-color Grid row border color (defaults to use cell border color)
    --b-grid-row-border-width Grid row border width (bottom border)
    --b-grid-row-height Grid's default row height, if not set programmatically or through data
    --b-grid-row-placeholder-color Row "Skeleton" background color when lazy loading
    --b-grid-row-transition-duration Transition duration for row operations such as adding and removing
    --b-grid-row-zindex Grid row z-index
    --b-grid-splitter-narrow-color Grid splitter color, when not using the RegionResize feature
    --b-grid-splitter-width Grid splitter width, when not using the RegionResize feature
    Focused
    --b-grid-cell-focused-outline-color Grid cell focused outline color
    --b-grid-cell-focused-outline-width Grid cell focused outline width
    Hovered
    --b-grid-cell-hover-background Background for hovered cells
    --b-grid-cell-hover-selected-background Background for hovered and selected cells
    Selected
    --b-grid-cell-selected-background Background for selected cells
    --b-grid-cell-selected-color Grid cell color when selected & hovered