Migration Guide to 2.x (2018-06-23)
Services
Angular-Slickgrid Services are no longer Singleton and are no longer available as Dependency Injection (DI) anymore, they are instead available in the Angular Grid Instance that can be obtained by the
onAngularGridCreatedEvent Emitter (see below)this is the biggest change, so please make sure to review the code sample below
Event Emitter
(onGridStateServiceChanged)renamed to(onGridStateChanged)GridExtraUtilno longer exist, it was containing only 1 functiongetColumnDefinitionAndData()that got moved into theGridServiceand renamed togetColumnFromEventArguments
Slick Grid & DataView objects
The Event Emitters (onGridCreated) and (onDataviewCreated) still exists but it is now much easier to get the Slick Grid & DataView objects directly from the (onAngularGridCreated) Event Emitter (it's an all in 1 emitter that includes Slick objects and Angular-Slickgrid Services)
see below
Column Definitions
Column Definition
onCellClickandonCellChangefunction signatures changed to be more in line with SlickGrid subscribed events and also to provide a way to stop event bubbling if user needs thatboth functions now have 2 arguments e.g.:
onCellChange?: (e: Event, args: OnEventArgs) => void;, see full example below
all the Editors options were previously passed through the generic
paramsproperty. However this which removes the benefit of intellisense (VScode) and TypeScript Type check, so all of these options got moved into theeditoroptions (see below)
Grid Options
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)
Editors
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 objectthe 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 theeditorwithmodelpropertythis also brings TypeScript types and intellisense to
collection,collectionFilterByandcollectionSortBy
Custom Editor is now also supported
see code change below
Filters
Select Filter (
FilterType.select) withselectOptionsgot renamed tocollectionpreviously we had
searchTerms(array) andsearchTerm(singular), but the lattersearchTermwas dropped in favor of using onlysearchTermsto remove duplicate logic code.FilterTypegot removed and you can now use directlyFilters, also to emphasis the change we renamed thefilterpropertytypetomodelsee example below
Backend Service API
For
BackendServiceApi, theserviceproperty now as to contain anewinstance of the Backend Service that you want to use (GraphqlServiceorGridOdataService). See explanation belowAll 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
@deprecated code removed
removed
onBackendEventApiwhich was replaced bybackendServiceApiremoved Select Filter
selectOptions, replaced bycollectionremoved
FormElementTypewhich was replaced byFilterTyperemoved
initOptionsfunction frombackendServiceApi, which was replaced byinitwith a different signatureremove
GridExtraUtilService
Code Refactoring Samples & Other Explanations
onAngularGridCreated instance
onAngularGridCreated instanceThis new instance will contain all the Angular-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 AngularGridInstance
AngularGridInstance interface
Note:
GridExtraServiceis now exported asGridServiceGroupingAndColspanServiceis now exported asGroupingServiceControlAndPluginServiceis now exported asPluginService
code change
View
Backend Service API - service with new
newexportWithFormatter flag
exportWithFormatter flagPreviously 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.
i18n now directly in Grid Options
i18n now directly in Grid Optionseditor new structure
editor new structurefilter new structure
filter new structureselectOptionsrenamed tocollectionFilterTypereplaced byFilterstyperenamed tomodelsearchTermremoved in favor of an array ofsearchTermsCustom Filter is now much simpler, just pass a new instance of your class
Column Definition Events
onCellChange and onCellClick now expose Event as the 1st argument to be in line with SlickGrid subscribed event
Grid Menu showX renamed to hideX
showX renamed to hideXSince these flags are now inverse, please do not forget to also inverse your boolean value.
Here is the entire list of Grid Menu
showClearAllFiltersCommandrenamed tohideClearAllFiltersCommandshowClearAllSortingCommandrenamed tohideClearAllSortingCommandshowExportCsvCommandrenamed tohideExportCsvCommandshowExportTextDelimitedCommandrenamed tohideExportTextDelimitedCommandshowRefreshDatasetCommandrenamed tohideRefreshDatasetCommandshowToggleFilterCommandrenamed tohideToggleFilterCommand
and here is the list for Header Menu showColumnHideCommand
showColumnHideCommandrenamed tohideColumnHideCommandshowSortCommandsrenamed tohideSortCommands
Backend Service onX methods renamed to processOnX
onX methods renamed to processOnXHere is the entire list
onFilterChangedwas renamed toprocessOnFilterChangedonPaginationChangedwas renamed toprocessOnPaginationChangedonSortChangedwas renamed toprocessOnSortChanged
Last updated