Skip to content

Commit

Permalink
Allow customizing the key property type (adazzle#2311)
Browse files Browse the repository at this point in the history
* Allow customizing the key property

* Update DataGrid.tsx

* Update DataGrid.tsx

* Update src/DataGrid.tsx

Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>

* update

* Update src/DataGrid.tsx

Co-authored-by: Nicolas Stepien <567105+nstepien@users.noreply.github.com>
  • Loading branch information
2 people authored and gernotkogler committed May 13, 2021
1 parent 825b9be commit 2c0dc71
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ type SharedDivProps = Pick<React.HTMLAttributes<HTMLDivElement>,
| 'style'
>;

export interface DataGridProps<R, SR = unknown> extends SharedDivProps {
export interface DataGridProps<R, SR = unknown, K extends React.Key = React.Key> extends SharedDivProps {
/**
* Grid and data Props
*/
Expand All @@ -94,7 +94,7 @@ export interface DataGridProps<R, SR = unknown> extends SharedDivProps {
*/
summaryRows?: readonly SR[];
/** The getter should return a unique key for each row */
rowKeyGetter?: (row: R) => React.Key;
rowKeyGetter?: (row: R) => K;
onRowsChange?: (rows: R[], data: RowsChangeData<R, SR>) => void;

/**
Expand All @@ -113,9 +113,9 @@ export interface DataGridProps<R, SR = unknown> extends SharedDivProps {
* Feature props
*/
/** Set of selected row keys */
selectedRows?: ReadonlySet<React.Key>;
selectedRows?: ReadonlySet<K>;
/** Function called whenever row selection is changed */
onSelectedRowsChange?: (selectedRows: Set<React.Key>) => void;
onSelectedRowsChange?: (selectedRows: Set<K>) => void;
/** The key of the column which is currently being sorted */
sortColumn?: string;
/** The direction to sort the sortColumn*/
Expand Down Expand Up @@ -1071,4 +1071,4 @@ function DataGrid<R, SR>({
);
}

export default forwardRef(DataGrid) as <R, SR = unknown>(props: DataGridProps<R, SR> & RefAttributes<DataGridHandle>) => JSX.Element;
export default forwardRef(DataGrid) as <R, SR = unknown, Key extends React.Key = React.Key>(props: DataGridProps<R, SR, Key> & RefAttributes<DataGridHandle>) => JSX.Element;

0 comments on commit 2c0dc71

Please sign in to comment.