-
-
Couldn't load subscription status.
- Fork 19
Migration to 2.x
- Aurelia-Slickgrid Services are no longer Singleton and are no longer available as Dependency Injection (DI) anymore, they are instead available in the Aurelia Grid Instance that can be obtained by the
onAureliaGridCreatedEvent Emitter (see below)- this is the biggest change, so please make sure to review the code sample below
- Event Dispatch
asg-on-grid-state-service-changedrenamed toasg-on-grid-state-changed -
GridExtraUtilno longer exist, it was containing only 1 functiongetColumnDefinitionAndData()that got moved into theGridServiceand renamed togetColumnFromEventArguments
The Event Aggregator onGridCreated and onDataviewCreated still exists but it is now much easier to get the Slick Grid & DataView objects directly from the new Aurelia Grid Instance Event Dispatch (it's an all in 1 emitter that includes Slick objects and Aurelia-Slickgrid Services)
- see below
- Column Definition
onCellClickandonCellChangesignature changed to be more in line with SlickGrid subscribed events and also to provide a way to stop event bubbling if user need that- both functions now have 2 arguments e.g.:
onCellChange?: (e: Event, args: OnEventArgs) => void;, see full example below
- both functions now have 2 arguments e.g.:
- For consistencies, all Grid Menu and Header Menu
showXflags were renamed tohideXto align with some of the SlickGridhideX(see below) -
exportWithFormatteris no longer available directly in the Grid Options, it is now underexportOptionsGrid Options (see below) -
i18nis now a Grid Options which is easier to deal with instead of using the genericparams(see below)
- all the Editors options were previously passed through the generic
paramsproperty. However this was removing the benefit of intellisense (VScode) and TypeScript Type checking. We moved all of these options into theeditorthat is now a complex object - the Grid Option
editoris now a complex object with the same structure as thefilterGrid Option. This also mean that all the arguments that were previously passed to the genericparamsare now passed in theeditorwithmodelproperty- this also brings TypeScript types and intellisense to
collection,collectionFilterByandcollectionSortBy
- this also brings TypeScript types and intellisense to
- Custom Editor is now also supported
- see code change below
- Select Filter (
FilterType.select) withselectOptionsgot renamed tocollection -
searchTermwas dropped in favor of onlysearchTermsto remove duplicate logic code. -
FilterTypegot removed and you can now use directlyFilters, also to emphasis the change we renamed thefilterpropertytypetomodel - see example below
- For
BackendServiceApi, theserviceproperty now as to contain anewinstance of the Backend Service that you want to use (GraphqlServiceorGridOdataService). See explanation below - All 3
onXservice methods were renamed toprocessOnXto remove confusion withonXEvent Emitters with the same names. (see below)- this will probably not concern you, unless you built your own custom Backend Service API
-
BackendServicemethodinitOptionsgot removed and replaced byinitwhich has a different argument signature
- removed
onBackendEventApiwhich was replaced bybackendServiceApi - removed Select Filter
selectOptions, replaced bycollection - removed
FormElementTypewhich was replaced byFilterType - removed
initOptionsfunction frombackendServiceApi, which was replaced byinitwith a different signature - remove
GridExtraUtilService
This new instance will contain all the Aurelia-Slickgrid Services (that were previously available as DI). As you can see below, you simply need to remove all DI and get a reference of the service you want through the AureliaGridInstance
Note:
-
GridExtraServiceis now exported asGridService -
GroupingAndColspanServiceis now exported asGroupingService -
ControlAndPluginServiceis now exported asPluginService
export interface AureliaGridInstance {
backendService?: BackendService;
pluginService: ControlAndPluginService;
exportService: ExportService;
filterService: FilterService;
gridService: GridService;
gridEventService: GridEventService;
gridStateService: GridStateService;
groupingService: GroupingAndColspanService;
resizerService: ResizerService;
sortService: SortService;
}<aurelia-slickgrid gridId="grid"
columnDefinitions.bind="columnDefinitions"
gridOptions.bind="gridOptions"
dataset.bind="dataset"
+ asg-on-aurelia-grid-greated="aureliaGridReady($event)">
</aurelia-slickgrid>export class MyGridDemo implements OnInit {
+ aureliaGrid: AureliaGridInstance;
columnDefinitions: Column[];
gridOptions: GridOption;
dataset: any[];
- constructor(private GridExtraService) {}
+ aureliaGridReady(aureliaGrid: AureliaGridInstance) {
+ this.aureliaGrid= aureliaGrid;
+ }
addNewItem() {
const newItem = {
id: newId,
title: 'Task ' + newId,
effortDriven: true,
// ...
};
- this.gridExtraService.addItemToDatagrid(newItem);
+ this.aureliaGrid.gridService.addItemToDatagrid(newItem);
}
export class MyGrid {
- constructor(private graphqlService: GraphqlService, private i18n: I18N) {
+ constructor(private i18n: I18N) {
}
this.gridOptions = {
backendServiceApi: {
- service: this.graphqlService,
+ service: new GraphqlService(),
preProcess: () => this.displaySpinner(true),
process: (query) => this.getCustomerApiCall(query),
postProcess: (result: GraphqlResult) => this.displaySpinner(false)
},
params: {
i18: this.translate
}
};Previously available directly in the grid options but is now accessible only from the exportOptions property. Also worth to know that the exportOptions contains much more options, you can see the exportOptions interface here.
this.gridOptions = {
- exportWithFormatter: true
exportOptions: {
+ exportWithFormatter: false,
}
};this.gridOptions = {
enableTranslate: true,
- params: {
- i18n: this.translate
- },
+ i18n: this.translate,
};import { Column, Editors, GridOption } from 'aurelia-slickgrid';
this.columnDefinitions = [
{
id: 'title', name: 'Title', field: 'title',
type: FieldType.string,
- editor: Editors.longText,
+ editor: {
+ model: Editors.longText
+ },
},
{
id: 'title2', name: 'Title, Custom Editor', field: 'title',
type: FieldType.string,
+ editor: {
// new CUSTOM EDITOR added
+ model: CustomInputEditor // no need to instantiate it
+ },
},
{
id: 'prerequisites', name: 'Prerequisites', field: 'prerequisites',
type: FieldType.string,
- editor: Editors.multipleSelect,
+ editor: {
+ model: Editors.multipleSelect,
+ collection: Array.from(Array(12).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` })),
+ collectionSortBy: {
+ property: 'label',
+ sortDesc: true
+ },
+ collectionFilterBy: {
+ property: 'label',
+ value: 'Task 2'
+ }
+ },
- params: {
- collection: Array.from(Array(12).keys()).map(k => ({ value: `Task ${k}`, label: `Task ${k}` })),
- collectionSortBy: {
- property: 'label',
- sortDesc: true
- },
- collectionFilterBy: {
- property: 'label',
- value: 'Task 2'
- }
- }
}
];-
selectOptionsrenamed tocollection -
FilterTypereplaced byFilters -
typerenamed tomodel -
searchTermremoved in favor of an array ofsearchTerms - Custom Filter is now much simpler, just pass a new instance of your class
- import { Column, FilterType } from 'aurelia-slickgrid';
+ import { Column, Filters } from 'aurelia-slickgrid';
// column definitions
this.columnDefinitions = [
{
id: 'isActive', name: 'Is Active', field: 'isActive',
type: FieldType.boolean,
filterable: true,
filter: {
- selectOptions: [ { value: '', label: '' }, { value: true, label: 'true' }, { value: false, label: 'false' } ],
+ collection: [ { value: '', label: '' }, { value: true, label: 'true' }, { value: false, label: 'false' } ],
- type: FilterType.multipleSelect,
+ model: Filters.multipleSelect,
searchTerms: [], // default selection
}
},
{
id: 'description', name: 'Description', field: 'description',
filter: {
- type: FilterType.custom,
- customFilter: CustomInputFilter
+ model: CustomInputFilter // create a new instance to make each Filter independent from each other
}
},
{
id: 'isActive', name: 'Is Active', field: 'isActive',
type: FieldType.boolean,
filterable: true,
filter: {
collection: [ { value: '', label: '' }, { value: true, label: 'true' }, { value: false, label: 'false' } ],
type: FilterType.multipleSelect,
- searchTerm: true, // default selection
+ searchTerms: [true], // default selection
}
}
];onCellChange and onCellClick now expose Event as the 1st argument to be in line with SlickGrid subscribed event
this.columnDefinitions = [{
id: 'delete',
field: 'id',
formatter: Formatters.deleteIcon,
- onCellClick: (args: OnEventArgs) => {
+ onCellClick: (e: Event, args: OnEventArgs) => {
alert(`Deleting: ${args.dataContext.title}`);
+ e.stopImmediatePropagation(); // you can stop event bubbling if you wish
}
}, {
id: 'title',
name: 'Title',
field: 'title',
- onCellChange: (args: OnEventArgs) => {
+ onCellChange: (e: Event, args: OnEventArgs) => {
alert(`Updated Title: ${args.dataContext.title}`);
}
}
];Since these flags are now inverse, please do not forget to also inverse your boolean value.
Here is the entire list of Grid Menu
-
showClearAllFiltersCommandrenamed tohideClearAllFiltersCommand -
showClearAllSortingCommandrenamed tohideClearAllSortingCommand -
showExportCsvCommandrenamed tohideExportCsvCommand -
showExportTextDelimitedCommandrenamed tohideExportTextDelimitedCommand -
showRefreshDatasetCommandrenamed tohideRefreshDatasetCommand -
showToggleFilterCommandrenamed tohideToggleFilterCommand
and here is the list for Header Menu showColumnHideCommand
-
showColumnHideCommandrenamed tohideColumnHideCommand -
showSortCommandsrenamed tohideSortCommands
Here is the entire list
-
onFilterChangedwas renamed toprocessOnFilterChanged -
onPaginationChangedwas renamed toprocessOnPaginationChanged -
onSortChangedwas renamed toprocessOnSortChanged
Contents
- Aurelia-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
- Add/Delete/Update or Highlight item
- Dynamically Change Row CSS Classes
- Column Picker
- Composite Editor Modal
- Context Menu
- Custom Tooltip
- Excel Copy Buffer
- Export to Excel
- Export to File (CSV/Txt)
- Grid Menu
- Grid State & Presets
- Grouping & Aggregators
- Header Menu & Header Buttons
- Header Title Grouping
- Pinning (frozen) of Columns/Rows
- Row Colspan
- Row Detail
- Row Selection
- Tree Data Grid
- SlickGrid & DataView objects
- Addons (controls/plugins)
- Backend Services