diff --git a/fixed-data-table/fixed-data-table-tests.tsx b/fixed-data-table/fixed-data-table-tests.tsx index f104ac5e4..916c0e64a 100644 --- a/fixed-data-table/fixed-data-table-tests.tsx +++ b/fixed-data-table/fixed-data-table-tests.tsx @@ -2,7 +2,7 @@ /// import * as React from "react"; -import {Table, Cell, Column} from "fixed-data-table"; +import {Table, Cell, Column, CellProps} from "fixed-data-table"; // create your Table class MyTable1 extends React.Component<{}, {}> { @@ -68,7 +68,7 @@ class MyTable3 extends React.Component<{}, MyTable3State> { height={500}> Name} - cell={(props: any) => ( + cell={(props: CellProps) => ( {this.state.myTableData[props.rowIndex].name} @@ -85,7 +85,7 @@ interface RowData { [field: string]: string; } -interface MyCellProps { +interface MyCellProps extends CellProps { rowIndex?: number; field: string; data: RowData[]; diff --git a/fixed-data-table/fixed-data-table.d.ts b/fixed-data-table/fixed-data-table.d.ts index a1400502e..5fb0438a0 100644 --- a/fixed-data-table/fixed-data-table.d.ts +++ b/fixed-data-table/fixed-data-table.d.ts @@ -284,13 +284,13 @@ declare module FixedDataTable { * * If you pass in a function, you will receive the same props object as the first argument. */ - header?: any; + header?: string | __React.ReactElement | ((props: CellProps) => (string | __React.ReactElement)); /** * This is the body cell that will be cloned for this * column. This can either be a string a React element, * or a function that generates a React Element. Passing - * in a string will render a default header cell with that + * in a string will render a default cell with that * string. By default, the React element passed in can * expect to receive the following props: * @@ -308,7 +308,7 @@ declare module FixedDataTable { * If you pass in a function, you will receive the same * props object as the first argument. */ - cell?: any; + cell?: string | __React.ReactElement | ((props: CellProps) => (string | __React.ReactElement)); /** * The footer cell for this column. This can either be a @@ -331,7 +331,7 @@ declare module FixedDataTable { * If you pass in a function, you will receive the same * props object as the first argument. */ - footer?: any; + footer?: string | __React.ReactElement | ((props: CellProps) => (string | __React.ReactElement)); /** * This is used to uniquely identify the column, and is not @@ -433,7 +433,7 @@ declare module FixedDataTable { * If you pass in a function, you will receive the same props * object as the first argument. */ - header: any; + header: string | __React.ReactElement | ((props: CellProps) => (string | __React.ReactElement)); } /** @@ -459,6 +459,11 @@ declare module FixedDataTable { * ); */ export interface CellProps { + /** + * The row index of the cell. + */ + rowIndex?: number + /** * Outer height of the cell. */ @@ -472,7 +477,7 @@ declare module FixedDataTable { /** * Optional prop that if specified on the Column will be * passed to the cell. It can be used to uniquely identify - * which column is the cell is in. + * which column is the cell is in. */ columnKey?: string | number; }