Describe the bug
When SlickgridReact is initialized with a customDataView prop, the component passes that custom DataView to new SlickGrid(...), but it does not assign it to the component's internal this.dataView.
In frameworks/slickgrid-react/src/components/slickgrid-react.tsx, this.dataView is only assigned inside:
if (!this.props.customDataView) {
this.dataView = new SlickDataView(...)
}
but later in the same initialization() method, the code still uses this.dataView:
if (typeof (this.dataView as SlickDataView).setGrid === 'function') {
this.dataView.setGrid(this.grid);
}
this.sharedService.dataView = this.dataView;
this.bindDifferentHooks(this.grid, this._options, this.dataView);
This means this.dataView can be undefined when customDataView is supplied, causing initialization to fail or leaving sharedService.dataView / instances.dataView unset.
Reproduction
Use SlickgridReact with a supplied customDataView:
<SlickgridReact
gridId="grid1"
columns={columns}
dataset={[]}
options={gridOptions}
customDataView={customDataView}
/>
During initialization(), customDataView is passed to new SlickGrid(...), but this.dataView is never assigned because the assignment only happens in the if (!this.props.customDataView) branch.
Current source reference:
frameworks/slickgrid-react/src/components/slickgrid-react.tsx
initialization()
customDataView branch around lines 484-529 in commit ba7a129f1
Which Framework are you using?
React
Expected behavior
When customDataView is provided, SlickgridReact should use it consistently as the internal DataView reference, e.g. assign:
this.dataView = this.props.customDataView;
before creating the SlickGrid or before any internal this.dataView access.
Actual behavior
customDataView is passed to new SlickGrid(...), but this.dataView remains unset because the internal assignment only happens in the non-custom DataView branch.
Suggested fix
Assign the custom DataView to the internal field when provided:
if (this.props.customDataView) {
this.dataView = this.props.customDataView;
} else {
const dataviewInlineFilters = (this._options.dataView && this._options.dataView.inlineFilters) || false;
let dataViewOptions: Partial<DataViewOption> = { ...this._options.dataView, inlineFilters: dataviewInlineFilters };
...
this.dataView = new SlickDataView<TData>(dataViewOptions as Partial<DataViewOption>, this._eventPubSubService);
this._eventPubSubService.publish('onDataviewCreated', this.dataView);
}
This keeps later internal references (setGrid, sharedService.dataView, bindDifferentHooks, SlickgridReactInstance.dataView) consistent for both internal and custom DataView cases.
Environment Info
| Executable | Version |
| ------------------- | ------- |
| Framework used | React / Slickgrid-React |
| Slickgrid-Universal | master, commit ba7a129f1 |
| TypeScript | N/A |
| Browser(s) | N/A |
| System OS | N/A |
Validations
Describe the bug
When
SlickgridReactis initialized with acustomDataViewprop, the component passes that custom DataView tonew SlickGrid(...), but it does not assign it to the component's internalthis.dataView.In
frameworks/slickgrid-react/src/components/slickgrid-react.tsx,this.dataViewis only assigned inside:but later in the same
initialization()method, the code still usesthis.dataView:This means
this.dataViewcan be undefined whencustomDataViewis supplied, causing initialization to fail or leavingsharedService.dataView/instances.dataViewunset.Reproduction
Use
SlickgridReactwith a suppliedcustomDataView:During
initialization(),customDataViewis passed tonew SlickGrid(...), butthis.dataViewis never assigned because the assignment only happens in theif (!this.props.customDataView)branch.Current source reference:
frameworks/slickgrid-react/src/components/slickgrid-react.tsxinitialization()customDataViewbranch around lines 484-529 in commitba7a129f1Which Framework are you using?
React
Expected behavior
When
customDataViewis provided,SlickgridReactshould use it consistently as the internal DataView reference, e.g. assign:before creating the SlickGrid or before any internal
this.dataViewaccess.Actual behavior
customDataViewis passed tonew SlickGrid(...), butthis.dataViewremains unset because the internal assignment only happens in the non-custom DataView branch.Suggested fix
Assign the custom DataView to the internal field when provided:
This keeps later internal references (
setGrid,sharedService.dataView,bindDifferentHooks,SlickgridReactInstance.dataView) consistent for both internal and custom DataView cases.Environment Info
Validations