-
-
Notifications
You must be signed in to change notification settings - Fork 120
Migration to 3.x
Before you start, make sure that you don't have any console log warnings (most of the deprecated code from 2.x
were already displaying some console warnings to advise you of what's being removed). So it will be easier to fix the console warnings first, then move on to the list of changes below.
NOTE: Last Angular-Slickgrid 3.x version is v3.3.2 and is compatible only with Slickgrid-Universal v0.19.2
- Slickgrid-Universal 1.x versions only works with Angular-Slickgrid 4.x (Migration Guide 4.x)
- Export to File & Export to Excel are now decoupled and opt-in (see Export Services below)
- since both exports are opt-in, they are now also both disabled by default
- Backend Service APIs are now decoupled and opt-in (see Backend Service API below)
- Remove
sg
event name prefix (in other words(sgOnBeforeEditCell)
becomes(onBeforeEditCell)
)- You can however put them back, in your grid options, to avoid having a lot of refactoring (see Grid Events below)
- Event Emitters are replaced with Custom Events (see Event Emitters below)
- the optional data, when provided, must now be accessed via
($event.detail)
instead of previously($event)
- the optional data, when provided, must now be accessed via
- Styling (css/sass) main files are now under the
@slickgrid-universal/common
monorepo (see Stylings below) - RxJS 7 is now the minimum version
- the biggest change that I saw so far was the
toPromise
deprecation and that was easy enough to replace withfirstValueFrom
- the biggest change that I saw so far was the
note: most of the deprecated code already sends you console warnings, so check your console first.
- removed all Grid Service methods having the word "toDatagrid" in their names
- for example,
addItemToDatagrid
,deleteDataGridItem
, ... - simply use the newer methods (named as
addItem
,deleteItemById
,updateItem
, ...), which have a lot more features and options.
- for example,
- removed
registerPlugins
Grid Option since all useful plugins/controls already exist in the lib. - removed
hideColumn(column)
please usehideColumnById
orhideColumnByIds
instead - removed
hideColumnByIndex(idx)
please usehideColumnById
orhideColumnByIds
instead - removed
BackendServiceOption
property namedcolumnDefinitions
, this is no longer a valid property which means that you cannot use it anymore with OData/GraphQL. This is no longer necessary since the Services can get the columns definition directly from the grid object. - removed SASS variables
$large-editor-textarea-height
$large-editor-textarea-width
The 3rd party lib named multiple-select.js
is no longer included within Angular-Slickgrid, it is now a separate npm package named multiple-select-modified
You will have to update the lib path in your angular.json
, simply update the path as shown below (note that the Slickgrid Bootstrap Theme CSS path portion is optional when using SASS)
"styles": [
"node_modules/flatpickr/dist/flatpickr.css",
- "node_modules/angular-slickgrid/lib/multiple-select/multiple-select.css",
- "node_modules/angular-slickgrid/styles/css/slickgrid-theme-bootstrap.css",
+ "node_modules/multiple-select-modified/src/multiple-select.css",
+ "node_modules/@slickgrid-universal/common/dist/styles/css/slickgrid-theme-bootstrap.css",
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/jquery-ui-dist/jquery-ui.min.js",
"node_modules/slickgrid/lib/jquery.event.drag-2.3.0.js",
"node_modules/bootstrap/dist/js/bootstrap.js",
- "node_modules/angular-slickgrid/lib/multiple-select/multiple-select.js"
+ "node_modules/multiple-select-modified/src/multiple-select.js",
],
You also need to modify the allowedCommonJsDependencies
option include assign-deep
, jquery-ui
(and stream
for WebPack 5) while angular-slickgrid
itself can be removed, so your updated option should be (for a full sample, take a look at this angular.json from 1 of the demo)
"allowedCommonJsDependencies": [
+ "assign-deep",
"excel-builder-webpacker",
+ "jquery-ui",
+ "stream"
]
and you should also update/create the ngcc.config.js
in the root of your project (or copy the code live demo)
module.exports = {
packages: {
'angular-slickgrid': {
ignorableDeepImportMatchers: [
+ /assign-deep/,
/slickgrid\//,
/flatpickr/,
+ /dequal/,
+ /jquery-ui\//,
]
},
}
};
- renamed
CheckboxSelector
interface toCheckboxSelectorOption
- renamed
EditorValidatorOutput
interface toEditorValidationResult
- renamed
Sorter
interface toSortComparer
- renamed
Sorters
toSortComparers
(often used when using the Grouping feature)
Note that the BackendServiceApi
is no longer exposed in the AngularGridInstance
, so if you wish to reference it (for example when you want to use it with an external export button), then create a reference while instantiating it or get it via the grid option this.gridOptions.backendServiceApi.service
-
headerKey
was replaced bynameKey
(to align with SlickGridname
property when using I18N with translations)
Removed grid events prefixes SlickGrid (sg
).
However please note that you can always add them back to avoid having to refactor all your grids at once, the main changes are in the global grid options:
export const GlobalGridOptions: Partial<GridOption> = {
+ eventNamingStyle: EventNamingStyle.camelCase,
}
In case you wish to keep sg
prefix (only for SlickGrid/DataView events) to avoid too many refactoring, then could optionally add them back in your grid options via this option:
this.gridOptions = {
defaultSlickgridEventPrefix: 'sg',
// ...
}
Every events available from Angular-Slickgrid (the events that didn't start with the sg
prefix, for example angularGridReady
) are no longer exported as Event Emitter, they are instead available as Custom Events so that all Events (regardless or where they come from, that is from Angular-Slickgrid, SlickGrid or the DataView) are now all exported as Custom Events and this also means that the optional data is now accessed the same way across all events via the event detail property. So you will need to change some of your events
- (onAngularGridCreated)="angularGridReady($event)"
+ (onAngularGridCreated)="angularGridReady($event.detail)"
You might have notice the eventNamingStyle
grid option, it is indeed a new option and with it you can change the names of the events following a defined naming convention. The default is camel case but you could also use the all lower case option (which is an acceptable ES6 syntax), if you take that for example that would become:
So the default is camelCase event naming:
<angular-slickgrid (onClick)="handleOnClick($event.detail)">
But if you wish to use all lower case, you can change your grid options with
this.gridOptions {
+ eventNamingStyle: EventNamingStyle.lowerCase,
}
That would result in all lower case names
<angular-slickgrid
- (onClick)="handleOnClick($event.detail)">
+ (onclick)="handleOnClick($event.detail)">
Again note that the entire documentation is written with event names following the default camel case format (onClick
).
- Grid Height/Width should now be passed through the Grid Options instead of the View, for example:
<angular-slickgrid gridId="grid1" [columnDefinitions]="columnDefinitions" [gridOptions]="gridOptions" [dataset]="dataset"
- gridHeight="225"
- gridWidth="800">
</angular-slickgrid>
were moved to the Grid Options in the ViewModel
this.gridOptions = {
+ gridHeight: 225,
+ gridWidth: 800 // or as a string like '100%'
};
- renamed
hideFilterCommands
to singularhideFilterCommand
since there can only be 1 filter per column
The CSS/SASS Stylings now come from the @slickgrid-universal/common
monorepo package, you need to adjust your imports
"styles": [
"node_modules/flatpickr/dist/flatpickr.css",
- "node_modules/angular-slickgrid/lib/multiple-select/multiple-select.css",
- "node_modules/node_modules/angular-slickgrid/styles/css/slickgrid-theme-bootstrap.css",
+ "node_modules/multiple-select-modified/src/multiple-select.css",
+ "node_modules/@slickgrid-universal/common/dist/styles/css/slickgrid-theme-bootstrap.css",
],
# with SASS
- @import 'angular-slickgrid/styles/sass/slickgrid-theme-bootstrap.scss';
+ @import '@slickgrid-universal/common/dist/styles/sass/slickgrid-theme-bootstrap.scss';
-
updateItem()
will no longer highlight the row by default (to get back this behavior add the optionhighlightRow: true
)
The GridOdataService
is now an opt-in Service and is no longer exposed in the AngularGridInstance
, you need create a reference while instantiating it or get it via the grid option this.gridOptions.backendServiceApi.service
- import { GridOdataService, OdataServiceApi, OdataOption } from 'angular-slickgrid';
+ import { GridOdataService, OdataServiceApi, OdataOption } from '@slickgrid-universal/odata';
export class MyExample {
prepareGrid {
this.columnDefinitions = [ /*...*/ ];
this.gridOptions = {
backendServiceApi: {
service: new GridOdataService(),
options: { /*...*/ } as OdataServiceApi
}
}
}
The GraphqlService
is now an opt-in Service and is no longer exposed in the AngularGridInstance
, you need create a reference while instantiating it or get it via the grid option this.gridOptions.backendServiceApi.service
- import { GraphqlService, GraphqlPaginatedResult, GraphqlServiceApi, } from 'angular-slickgrid';
+ import { GraphqlService, GraphqlPaginatedResult, GraphqlServiceApi, } from '@slickgrid-universal/graphql';
export class MyExample {
prepareGrid {
this.columnDefinitions = [ /*...*/ ];
this.gridOptions = {
backendServiceApi: {
service: new GraphqlService(),
options: { /*...*/ } as GraphqlServiceApi
}
}
}
Export Service was renamed to TextExportService
(export extensions are .txt
, .csv
) and is now an opt-in Servicem it is also no longer exposed in the AngularGridInstance
. You need to use the new @slickgrid-universal/text-export
packages and register the service(s) in your grid options as shown below.
Also note that Text Export Service grid options changed as well, a few options got deprecated and renamed to have the word "textExport" instead of just "export". Also to be clear, it's deprecated but still exist, this will give you time to refactor your code. Here's the list
- deprecate
exportOptions
and renamed totextExportOptions
- deprecate
enableExport
flag and renamed toenableTextExport
- the onBefore/onAfter events got renamed as well:
-
onGridBeforeExportToExcel
renamed toonBeforeExportToExcel
-
onGridAfterExportToExcel
renamed toonAfterExportToExcel
-
onGridBeforeExportToFile
renamed toonBeforeExportToTextFile
-
onGridAfterExportToFile
renamed toonAfterExportToTextFile
-
import { Column, GridOption } from 'angular-slickgrid';
+ import { ExcelExportService } from '@slickgrid-universal/excel-export';
+ import { TextExportService } from '@slickgrid-universal/text-export';
export class MyExample {
prepareGrid {
this.columnDefinitions = [ /*...*/ ];
this.gridOptions = {
enableExcelExport: true,
excelExportOptions: { sanitizeDataExport: true },
- enableExport: true,
- exportOptions: { sanitizeDataExport: true },
+ enableTextExport: true,
+ textExportOptions: { sanitizeDataExport: true },
// add 2x Export Services (you can add a single or both export services, it should always be an array
+ registerExternalResources: [new ExcelExportService(), new TextExportService()],
}
}
}
The ExcelExportService
is also an opt-in Service and is no longer exposed in the AngularGridInstance
, so if you wish to reference it (for example when you want to use it with an external export button), then create a reference while instantiating it (the excelExportOptions
are the same as before).
import { Column, GridOption } from 'angular-slickgrid';
+ import { ExcelExportService } from '@slickgrid-universal/excel-export';
export class MyExample {
+ excelExportService = new ExcelExportService(); // create a variable ref when you need to access it later
prepareGrid {
this.columnDefinitions = [ /*...*/ ];
this.gridOptions = {
enableExcelExport: true,
excelExportOptions: { sanitizeDataExport: true },
+ registerExternalResources: [this.excelExportService],
}
}
exportToExcel() {
- this.angularGrid.excelExportService.exportToExcel({ filename: 'Export', format: FileType.xlsx });
+ this.excelExportService.exportToExcel({ filename: 'export', format: FileType.xlsx });
}
}
The Custom Footer component is now an external reusable component coming from Slickgrid-Universal and the dateFormat
changed, it is now using the MomentJS date format (which is the same as all other Date Formatter) instead of the previous Angular date format. The changes in the global grid options is shown below, if you had it defined in your own grid options then make sure to use the correct format
customFooterOptions: {
- dateFormat: 'yyyy-MM-dd, hh:mm aaaaa\'m\'',
+ dateFormat: 'YYYY-MM-DD, hh:mm a',
// ...
}
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