-
-
Notifications
You must be signed in to change notification settings - Fork 119
SlickGrid & DataView Objects
In some cases you might want a feature that is not yet available in Angular-Slickgrid
but exists in the original SlickGrid
, what should you do? Fear not, we got you covered. Angular-Slickgrid
exposes the SlickGrid Grid
and DataView
objects through Event Emitters, these objects are created when Angular-Slickgrid initialize the grid (with ngAfterViewInit
). The ones we want to use for our usage would be onGridCreated
and onDataviewCreated
, depending on which object you want to obtain.
The new preferred way is now to use the AngularGridInstance
via the onAngularGridCreated
Event Emitter
Angular-Slickgrid have the following Event Emitters that you can hook to
onAngularGridCreated
onDataviewCreated
onGridCreated
onBeforeGridCreate
onBeforeGridDestroy
onAfterGridDestroyed
The ones we want to use for our usage would be onGridCreated
and onDataviewCreated
, depending on which object you want to obtain.
Since version 1.x
, we can now access the Slick Grid
& DataView
objects directly from the AngularGridInstance
through the (onAngularGridCreated)
Event Emitter, for example:
<span id="radioAutoEdit">
<label class="radio-inline control-label" for="radioTrue">
<input type="radio" name="inlineRadioOptions" id="radioTrue" checked [value]="isAutoEdit" (change)="setAutoEdit(true)"> ON (single-click)
</label>
<label class="radio-inline control-label" for="radioFalse">
<input type="radio" name="inlineRadioOptions" id="radioFalse" [value]="isAutoEdit" (change)="setAutoEdit(false)"> OFF (double-click)
</label>
</span>
<angular-slickgrid gridId="grid2"
[columnDefinitions]="columnDefinitions"
[gridOptions]="gridOptions"
[dataset]="dataset"
(onAngularGridCreated)="angularGridReady($event.detail">
</angular-slickgrid>
import { AngularGridInstance, Column, GridOption } from 'angular-slickgrid';
export class MyApp {
angularGrid: AngularGridInstance;
columnDefinitions: Column[];
gridOptions: GridOption;
dataset: any[];
isAutoEdit = true;
gridObj: any;
dataViewObj: any;
angularGridReady(angularGrid: AngularGridInstance) {
this.angularGrid = angularGrid;
this.gridObj = angularGrid.slickGrid;
this.dataViewObj = angularGrid.dataView;
}
/** Change dynamically `autoEdit` grid options */
setAutoEdit(isAutoEdit) {
this.isAutoEdit = isAutoEdit;
this.gridObj.setOptions({ autoEdit: isAutoEdit }); // change the grid option dynamically
return true;
}
collapseAllGroups() {
this.dataviewObj.collapseAllGroups();
}
expandAllGroups() {
this.dataviewObj.expandAllGroups();
}
}
You have access to all original SlickGrid events which you can subscribe, for more info refer to the Wiki - Grid & DataView Events
There's already all the necessary information on how to use this on the Wiki - Grid & DataView Events page, so I suggest you to head over to that Wiki page on how to use the SlickGrid
and DataView
objects
Contents
- Angular-Slickgrid Wiki
- Installation
- Styling
- Interfaces/Models
- Testing Patterns
- Column Functionalities
- Global Grid Options
- Localization
- Events
- Grid Functionalities
- Auto-Resize / Resizer Service
- Resize by Cell Content
- Composite Editor
- Context Menu
- Custom Tooltip
- Add/Delete/Update or Highlight item
- Dynamically Change Row CSS Classes
- Excel Copy Buffer
- Export to Excel
- Export to File (CSV/Txt)
- Grid State & Presets
- Grouping & Aggregators
- Row Detail
- SlickGrid Controls
- SlickGrid Plugins
- Pinning (frozen) of Columns/Rows
- Tree Data Grid
- SlickGrid & DataView objects
- Addons (controls/plugins)
- Backend Services