On Events
SlickGrid has a nice amount of events, see the full list of Available Events, which you can use by simply hook a subscribe to them (the subscribe are a custom SlickGrid Event). There are 2 options to get access to all these events (For the first 2 you will have to get access to the Grid and the DataView objects which are exposed in Aurelia-Slickgrid):
From the list below, the number 1. is by far the easiest and preferred way
with
delegateEvent Dispatch binding so you can add event handlers in your view. This library bubbles all events for the Grid and DataView by converting the camelcase methods to kebab case (ie. onMouseEnter will be on-mouse-enter. Slickgrid's EventData and Args parameters will be passed via $event.detail.eventData and $event.detail.argswith
bindablevalues, so you can just callgridChangedand/ordataviewChanged
1. Example with delegate Event Dispatch (asgOnX)
delegate Event Dispatch (asgOnX)Event Dispatch is the preferred way to access any of the Available Events
All the Slick Grid events (and DataView) are exposed through Event Dispatch and are available as (sgOnX)and that's it.
View
<aurelia-slickgrid
grid-id="gridId"
columns.bind="columnDefs"
options.bind="gridOptions"
dataset.bind="myDataset"
on-aurelia-grid-created.trigger="aureliaGridReady($event.detail)"
on-click.trigger="onCellClicked($event.detail.eventData, $event.detail.args)"
on-cell-change.trigger="onCellChanged($event.detail.eventData, $event.detail.args)"
on-mouse-enter.trigger="onMouseEntered($event.detail.eventData, $event.detail.args)">
</aurelia-slickgrid>Component
Hook yourself to the Changed event of the bindable grid object.
Available Dispatched Events
on-before-export-to-excel
on-after-export-to-excel
on-before-export-to-text-file
on-after-export-to-text-file
on-grid-state-changed
on-items-added
on-items-deleted
on-items-updated
on-items-upserted
on-grid-before-resize
on-grid-after-resize
2. Example with Bindable Grid/Dataview
View
Bind dataview.bind and grid.bind
ViewModel
Hook yourself to the Changed event of the bindable grid object.
How to use Grid/Dataview Events
Once the Grid and DataView are ready, see all Available Events. See below for the gridChanged(grid) and dataviewChanged(dataview) functions.
The
GridExtraUtilsis to bring easy access to common functionality like getting acolumnfrom it'srowandcellindex.The example shown below is subscribing to
onClickand ask the user to confirm a delete, then will delete it from theDataView.Technically, the
GridandDataVieware created at the same time byAurelia-Slickgrid, so it's ok to call thedataViewObjwithin some code of thegridObjChanged()function sinceDataViewobject will already be available at that time.
Note The example below is demonstrated with bind with event Changed hook on the grid and dataview objects. However you can also use the EventAggregator as shown earlier. It's really up to you to choose the way you want to call these objects.
ViewModel
Last updated