diff --git a/README.md b/README.md index 10743831f..6394738d6 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ npm start http://localhost:8000/examples/ -online example: http://react-component.github.io/table/build/examples/ +online example: http://react-component.github.io/table/examples/ ## Usage @@ -65,13 +65,15 @@ React.renderComponent( ### property -#### keyField +#### keyFn -* key value of each row +`Function(recode):string` + +* get key value of each row from each row record data #### columns * The columns config of table - + * key : key of this column * title : The title of column * dataIndex : display the data field * width : The width of column. The width of the specific proportion calculation according to the width of the columns diff --git a/examples/key.js b/examples/key.js index ff69f8201..ff9001481 100644 --- a/examples/key.js +++ b/examples/key.js @@ -42,16 +42,20 @@ var MyTable = React.createClass({ return 删除; }, + getKey(record){ + return record.a; + }, + render: function() { var state = this.state; var columns = [ - { title: '表头1', dataIndex: 'a', width: 100, renderer: this.checkbox }, - { title: '表头2', dataIndex: 'b', width: 100}, - { title: '表头3', dataIndex: 'c', width: 200}, - { title: '操作', dataIndex: '', renderer: this.renderAction } + { title: '表头1', dataIndex: 'a', key:'a', width: 100, renderer: this.checkbox }, + { title: '表头2', dataIndex: 'b', key:'b', width: 100}, + { title: '表头3', dataIndex: 'c', key:'c', width: 200}, + { title: '操作', dataIndex: '', key:'x', renderer: this.renderAction } ]; return ( -
{text} | ); + cells.push({text} | ); } return (