File tree Expand file tree Collapse file tree 3 files changed +6
-6
lines changed
spec/pivotal-ui-react/sortable-table
src/pivotal-ui-react/sortable-table Expand file tree Collapse file tree 3 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -257,7 +257,7 @@ describe('SortableTable', function() {
257
257
{
258
258
attribute : 'title' ,
259
259
displayName : 'Title' ,
260
- CustomCell : ( { value, index} ) => < td className = "custom" > { `${ index } : ${ value } ` } </ td >
260
+ CustomCell : ( { value, index, rowDatum } ) => < td className = "custom" > { `${ rowDatum . instances } - ${ index } : ${ value } ` } </ td >
261
261
} ,
262
262
{
263
263
attribute : 'instances' ,
@@ -288,9 +288,9 @@ describe('SortableTable', function() {
288
288
} ) ;
289
289
290
290
it ( 'uses custom for the column' , function ( ) {
291
- expect ( 'tbody tr:nth-of-type(1) > td:eq(0)' ) . toContainText ( '0: foo' ) ;
291
+ expect ( 'tbody tr:nth-of-type(1) > td:eq(0)' ) . toContainText ( '1- 0: foo' ) ;
292
292
expect ( 'tbody tr:nth-of-type(1) > td:eq(0)' ) . toHaveClass ( 'custom' ) ;
293
- expect ( 'tbody tr:nth-of-type(2) > td:eq(0)' ) . toContainText ( '1: sup' ) ;
293
+ expect ( 'tbody tr:nth-of-type(2) > td:eq(0)' ) . toContainText ( '3- 1: sup' ) ;
294
294
expect ( 'tbody tr:nth-of-type(2) > td:eq(0)' ) . toHaveClass ( 'custom' ) ;
295
295
} ) ;
296
296
} ) ;
Original file line number Diff line number Diff line change @@ -73,7 +73,7 @@ export const SortableTable = React.createClass({
73
73
return sortedData . map ( ( datum , rowKey ) => {
74
74
const cells = columns . map ( ( { attribute, CustomCell} , key ) => {
75
75
const Cell = CustomCell || TableCell ;
76
- return < Cell key = { key } index = { rowKey } value = { datum [ attribute ] } > { datum [ attribute ] } </ Cell > ;
76
+ return < Cell key = { key } index = { rowKey } value = { datum [ attribute ] } rowDatum = { datum } > { datum [ attribute ] } </ Cell > ;
77
77
} ) ;
78
78
79
79
const Row = CustomRow || TableRow ;
Original file line number Diff line number Diff line change @@ -135,7 +135,7 @@ var CustomRow = React.createClass({
135
135
The `TableCell` component is provided for users who wish to customize their cells
136
136
with the `CustomCell` attribute on the `columns` prop. If a custom cell is provided, the table will use that
137
137
component to render each cell, giving it a `value` prop representing the attribute from the datum for that row and `index`
138
- representing the (zero-indexed) row number.
138
+ representing the (zero-indexed) row number. For more advanced use cases, the `rowDatum` prop is also passed into the custom cell.
139
139
140
140
Note that sorting occurs on the actual data.
141
141
Changing the presentation of the data does not affect the sort behavior.
@@ -145,7 +145,7 @@ var CustomRow = React.createClass({
145
145
render() {
146
146
return (
147
147
<TableCell>
148
- {this.props.index}: {this.props.value}
148
+ {this.props.index}: {this.props.value} - {this.props.rowDatum.bar}
149
149
</TableCell>
150
150
);
151
151
}
You can’t perform that action at this time.
0 commit comments