Skip to content

Commit

Permalink
feat(setData): allow mutating of the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
scamden committed May 1, 2020
1 parent 3fcef66 commit 8fc9bda
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/lib/components/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface IGridProps extends IGridOpts {
data?: Array<Array<IGridDataResult<any>>>;
cellRenderer?(context: IBuilderUpdateContext): ReactElement<any> | string | undefined;
headerCellRenderer?(context: IBuilderUpdateContext): ReactElement<any> | string | undefined;
setData?(changes: Array<IGridDataChange<any>>): void;
setData?(changes: Array<IGridDataChange<any>>): Array<IGridDataChange<any>> | undefined;
}

export interface IGridState { }
Expand Down Expand Up @@ -58,10 +58,9 @@ export class ReactGrid extends Component<IGridProps, IGridState> {

}]
: rowOrData;
if (this.props.setData) {
this.props.setData(dataChanges);
}
origSet.call(this.grid.dataModel, dataChanges);

const newChanges = this.props.setData && this.props.setData(dataChanges) || dataChanges;
origSet.call(this.grid.dataModel, newChanges);
};
}

Expand Down

0 comments on commit 8fc9bda

Please sign in to comment.