From 90e82969495feecbf35e8864c8c9acde95638763 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 28 Aug 2015 15:22:09 +0800 Subject: [PATCH] Fix table key warning --- components/table/demo/basic.md | 3 +++ components/table/demo/bordered.md | 3 +++ components/table/demo/data.json | 10 ++++++++++ components/table/demo/head.md | 4 ++++ components/table/demo/local-data.md | 8 ++++++-- components/table/demo/nopagination.md | 3 +++ components/table/demo/paging.md | 1 + components/table/demo/row-selection.md | 3 +++ components/table/demo/small.md | 3 +++ components/table/index.jsx | 14 +++++++++----- components/table/index.md | 3 +++ 11 files changed, 48 insertions(+), 7 deletions(-) diff --git a/components/table/demo/basic.md b/components/table/demo/basic.md index d835aab703..7158af68f3 100644 --- a/components/table/demo/basic.md +++ b/components/table/demo/basic.md @@ -36,14 +36,17 @@ var columns = [{ } }]; var data = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' diff --git a/components/table/demo/bordered.md b/components/table/demo/bordered.md index c0672b2c80..80468f0596 100644 --- a/components/table/demo/bordered.md +++ b/components/table/demo/bordered.md @@ -23,14 +23,17 @@ var columns = [{ }]; var data = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' diff --git a/components/table/demo/data.json b/components/table/demo/data.json index 26e2308c4c..0617fc7b20 100644 --- a/components/table/demo/data.json +++ b/components/table/demo/data.json @@ -1,41 +1,51 @@ { "data": [{ + "key": "1", "name": "胡彦斌ajax1", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "2", "name": "胡彦祖ajax2", "age": 42, "address": "西湖区湖底公园1号" }, { + "key": "3", "name": "李大嘴ajax3", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "4", "name": "李大嘴ajax4", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "5", "name": "李大嘴ajax5", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "6", "name": "李大嘴ajax6", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "7", "name": "李大嘴ajax7", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "8", "name": "李大嘴ajax8", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "9", "name": "李大嘴ajax9", "age": 32, "address": "西湖区湖底公园1号" }, { + "key": "10", "name": "李大嘴ajax10", "age": 32, "address": "西湖区湖底公园1号" diff --git a/components/table/demo/head.md b/components/table/demo/head.md index f466468cb7..e6c4665d60 100644 --- a/components/table/demo/head.md +++ b/components/table/demo/head.md @@ -43,18 +43,22 @@ var columns = [{ }]; var data = [{ + key: '1', name: '胡斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园12号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园123号' }, { + key: '4', name: '李秀莲大嘴哥', age: 32, address: '西湖区湖底公园123号' diff --git a/components/table/demo/local-data.md b/components/table/demo/local-data.md index 873c587e89..5042feade6 100644 --- a/components/table/demo/local-data.md +++ b/components/table/demo/local-data.md @@ -22,34 +22,38 @@ var columns = [{ dataIndex: 'address' }]; var data1 = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' }]; var data2 = [{ + key: '11', name: '胡彦斌2', age: 32, address: '西湖区湖底公园2号' }, { + key: '22', name: '胡彦祖2', age: 42, address: '西湖区湖底公园2号' }, { + key: '33', name: '李大嘴2', age: 32, address: '西湖区湖底公园2号' }]; - - var App = React.createClass({ getInitialState() { return { diff --git a/components/table/demo/nopagination.md b/components/table/demo/nopagination.md index 1feabbf1e3..59d47a1469 100644 --- a/components/table/demo/nopagination.md +++ b/components/table/demo/nopagination.md @@ -20,14 +20,17 @@ var columns = [{ }]; var data = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' diff --git a/components/table/demo/paging.md b/components/table/demo/paging.md index f90a5b33a5..03a0249945 100644 --- a/components/table/demo/paging.md +++ b/components/table/demo/paging.md @@ -26,6 +26,7 @@ var data = []; for (let i=0; i<46; i++) { data.push({ + key: i, name: '李大嘴' + i, age: 32, address: '西湖区湖底公园' + i + '号' diff --git a/components/table/demo/row-selection.md b/components/table/demo/row-selection.md index 30e06b4872..0e964d400a 100644 --- a/components/table/demo/row-selection.md +++ b/components/table/demo/row-selection.md @@ -22,14 +22,17 @@ var columns = [{ dataIndex: 'address' }]; var data = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' diff --git a/components/table/demo/small.md b/components/table/demo/small.md index 85bb561f14..232804f29c 100644 --- a/components/table/demo/small.md +++ b/components/table/demo/small.md @@ -19,14 +19,17 @@ var columns = [{ dataIndex: 'address' }]; var data = [{ + key: '1', name: '胡彦斌', age: 32, address: '西湖区湖底公园1号' }, { + key: '2', name: '胡彦祖', age: 42, address: '西湖区湖底公园1号' }, { + key: '3', name: '李大嘴', age: 32, address: '西湖区湖底公园1号' diff --git a/components/table/index.jsx b/components/table/index.jsx index 056f1fadbd..c8bab21a63 100644 --- a/components/table/index.jsx +++ b/components/table/index.jsx @@ -295,11 +295,11 @@ var AntTable = React.createClass({ ; } - column.title = [ - column.title, - sortButton, - filterDropdown - ]; + column.title =
+ {column.title} + {sortButton} + {filterDropdown} +
; return column; }); }, @@ -467,6 +467,10 @@ var AntTable = React.createClass({ classString += ' ant-table-bordered'; } columns = this.renderColumnsDropdown(columns); + columns = columns.map((column, i) => { + column.key = column.dataIndex || i; + return column; + }); return