-
-
Notifications
You must be signed in to change notification settings - Fork 12
Custom Backend Service
The lib currently supports OData and GraphQL with built-in Services, if you want to use and create a different and Custom Backend Service, then follow the steps below.
To create your own Custom Backend Service, I suggest you take the code of the GraphqlService and rewrite the internal of each methods. The thing to remember is that you have to implement the BackendService
as defined in the GraphqlService (export class GraphqlService implements BackendService
).
You typically want to implement your service following these TypeScript interfaces
At the end of it, you'll have a Custom Backend Service that will be instantiated just like the GraphQL or OData that I've created, it should look similar to this (also note, try to avoid passing anything in the constructor
of your Service to keep it usable by everyone)
export class GridBasicComponent extends React.Component<Props, State> {
defineGrid() {
const gridOptions = {
backendServiceApi: {
service: new YourCustomBackendService(),
options: {
// custom service options that extends "backendServiceOption" interface
},
preProcess: () => !this.isDataLoaded ? this.displaySpinner(true) : '',
process: (query) => this.getCountries(query),
postProcess: (result) => {
this.displaySpinner(false);
this.isDataLoaded = true;
}
} as YourCustomBackendServiceApi
};
}
}
If you need to reference your Service for other purposes then you better instantiated in a separate variable and then just pass it to the service
property of the backendServiceApi
.
export class GridBasicComponent extends React.Component<Props, State> {
myCustomService = new YourCustomBackendService();
gridInit {
const gridOptions = {
backendServiceApi: {
service: this.myCustomService,
// ...
} as YourCustomBackendServiceApi
};
}
If your Service is for a well known DB or API framework, then it might be possible to add your Service to the lib itself, however it should be added to the new monorepo lib Slickgrid-Universal in the list of slickgrid-universal/packages. Since that is a monorepo lib, users will have the ability to use and download only the package they need.
Contents
- Slickgrid-React Wiki
- Installation
- Styling
- Interfaces/Models
- 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