Split
Feature
This feature allows splitting the Grid into multiple views, either by using the cell context menu, or programmatically by calling split().
const grid = new Grid({ appendTo : targetElement, height : '30em', features : { // Enable the Split feature split : true }, data : DataGenerator.generateData(50), columns : [ { field : 'firstName', text : 'First name', width : 150 }, { field : 'surName', text : 'Surname', width : 150 }, { field : 'city', text : 'City', width : 150 }, { type : 'date', field : 'start', text : 'Start', width : 150 }, { type : 'date', field : 'finish', text : 'Finish', width : 150 }, { type : 'number', field : 'score', text : 'Score', width : 150 }, { type : 'number', field : 'age', text : 'Age', width : 150 }, { type : 'rating', field : 'rank', text : 'Rank', width : 150 } ] }); grid.split({ direction : 'vertical' }); It handles splitting in 3 "directions":
'horizontal'- Splitting the grid into 2 sub-views, one above the other.'vertical'- Splitting the grid into 2 sub-views, one to the left of the other.'both'- Splitting the grid into 4 sub-views, one in each corner.
Or, by supplying a record and/or a column to split by.
The first sub-view (top, left or top-left depending on split direction) is the original grid, and the others are clones of the original. The clones share the same store, columns and selection.
Sub-views in the same column sync their scrolling horizontally, and sub-views in the same row sync their scrolling vertically.
Sub-views are separated by splitters, that can be dragged to resize the views.
Splitting a multi-region grid (two regions supported) only includes the region in which the split was performed in the split view.
Splitting works best on grids that use fixed column widths, since flexed columns will resize when the grid is split.
Splitting programmatically
The split feature assigns two methods to the owning grid:
Use them to split programmatically in your app.
// Split horizontally (eg. at the row in the center of the grid)
await grid.split({ direction : 'horizontal' });
// Split both ways by a specific column and record
await grid.split({
atRecord : grid.store.getById(10),
atColumn : grid.columns.get('city')
});
// Remove splits, returning to a single grid
grid.unsplit();
Splitting using the cell context menu
The feature also adds a new sub-menu to the cell context menu, allowing the user to split (or un-split) the grid. See the API documentation for the CellMenu feature for more information on how to customize the sub-menu.
Accessing a sub-view
The sub-views are accessed by index. The original grid is at index 0, and the others are as shown below. For 'horizontal' splits:
For 'vertical' splits:
For 'both' splits:
The subViews property returns an array containing all sub-views, including the original. Note that the property is also exposed on the owning Grid. Access a specific sub-view by index (see illustrations above). For example to access the bottom right sub-view in a 'both' split:
await grid.split({ direction : 'both' });
const bottomRight = grid.subViews[3];
await bottomRight.scrollRowIntoView(100);
Troubleshooting
The splits are inserted into a container element (which has the .b-split-container CSS class), replacing the original grid. If it does not render correctly out of the box, you should make sure that any CSS rules you have that apply size to the grid also applies to the container element.
For example if you use a CSS flex rule to size the grid:
.b-grid {
// Size grid using flex
flex : 3;
}
Then you should also apply the same rule to the container element:
.b-grid,
.b-split-container {
flex : 3;
}
This feature is disabled by default.
See also
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Internal listeners, that cannot be removed by the user.
-
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
-
Set to
falseto disable localization of this object.
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 Localizable class, or subclass thereof.
-
Identifies an object as an instance of Split class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
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 InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of Split 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). -
The Widget which was passed into the constructor, which is the Widget we are providing extra services for.
Has a corresponding client config.
-
Get the global LocaleHelper
-
Get the global LocaleManager
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
-
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.
-
This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.
Events
Events are triggered for certain actions in this class and can be listened for to react to those actions in your code-
unsplitON-OWNER
Fires when un-splitting the Grid.
Note that this event is triggered on the owning widget:
Event handlers
Event handlers are callbacks called as a result of certain actions in this class-
onUnsplitON-OWNER
Called when un-splitting the Grid.
Note that this handler is called on the owning widget: