GridBase
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
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
An object containing Feature configuration objects (or
trueif no configuration is required) keyed by the Feature class name in all lowercase. -
keyMap : Object<String, KeyMapConfig>
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.
- insertRecord : Boolean
-
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
trueto 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
falseto only measure cell contents when double-clicking the edge between column headers. -
Deprecated:
7.0.0 Deprecated
animateFilterRemovals. Usetransition.filterRemovalinsteadSet to
trueto animate row removals caused by filtering. -
Deprecated:
7.0.0 Deprecated
animateRemovingRows. Usetransition.removeRecordinsteadControls if removing and inserting rows should be animated. Set to
falseto prevent those animations, removing the related delays. -
Set to
falseto crop text in grid cells without ellipsis (...). When enabled, cells containing pure usedisplay : block, instead ofdisplay : flexto allow ellipsis to work. NOTE Only supported in browsers that support:has()CSS selectorHas a corresponding runtime cellEllipsis property.
-
Set to
falseto not show column lines. End result might be overruled by/differ between themes.Has a corresponding runtime columnLines property.
-
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
trueto destroy the store when the grid is destroyed. -
Set to
trueto 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. -
Deprecated:
7.3.0 Use
features : { stickyCells : true }insteadSet to
trueto 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
trueto hide the column header elementsHas a corresponding runtime hideHeaders property.
-
Set to
trueto hide the Grid's horizontal scrollbar(s) -
Grids change the
maskDefaultsto cover only theirbodyelement. -
Grid monitors window resize by default.
-
True to preserve focused cell after loading new data
-
Specify
trueto preserve vertical scroll position after store actions that trigger arefreshevent, such as loading new data and filtering. -
Set to
falseto 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
trueto allow text selection in the grid cells. Note, this cannot be used simultaneously with theRowReorderfeature. -
Set to
trueto not get a warning when calling getState when there is a column configured without anid. But the recommended action is to always configure columns with anidwhen using states. -
Deprecated:
7.0.0 Deprecated
animateTreeNodeToggle. Usetransition.toggleTreeNodeinsteadWhen the Tree feature is in use and the Store is a tree store, this config may be set to
trueto visually animate branch node expand and collapse operations.This is not supported in Scheduler and GanttHas a corresponding runtime animateTreeNodeToggle property.
Properties
Properties are getters/setters or publicly accessible variables on this class-
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.
-
Returns content height calculated from row manager
-
Identifies an object as an instance of GridBase class, or subclass thereof.
-
Body height
-
Header height
-
Set to
falseto crop text in grid cells without ellipsis (...). When enabled, cells containing pure usedisplay : block, instead ofdisplay : flexto allow ellipsis to work. NOTE Only supported in browsers that support:has()CSS selectorHas a corresponding cellEllipsis config.
-
Set to
falseto not show column lines. End result might be overruled by/differ between themes.Has a corresponding columnLines config.
-
Set to
trueto hide the column header elementsHas a corresponding hideHeaders config.
-
Set to
falseto 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.
-
Get the Row currently displayed furthest down.
-
Get the topmost visible grid row
-
Get the last visible grid row
-
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.
-
Deprecated:
7.0.0 Deprecated
animateTreeNodeToggle. Usetransition.toggleTreeNodeinsteadWhen the Tree feature is in use and the Store is a tree store, this config may be set to
trueto visually animate branch node expand and collapse operations.This is not supported in Scheduler and GanttHas a corresponding animateTreeNodeToggle config.
Functions
Functions are methods available for calling on the class-
captureScrollTargetRow( )private
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.
-
refreshVirtualScrollbars( )private
Recalculates virtual scrollbars widths and scrollWidth
-
restoreScrollTargetRow( )private
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
-
unmaskBody( )
Hide the load mask.
-
Rerenders all grid headers
-
Rerenders the grids rows, headers and footers, completely replacing all row elements with new ones
-
renderRows( )
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
-
onStoreAfterRequest( )private
Hides load mask after a load request ends either in success or failure
-
onStoreBeforeRequest( )private
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
-
onStoreRecordIdChange( )private
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
-
onStoreUpdateRecord( )private
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
-
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.
-
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.
-
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.