This commit is contained in:
yiminghe 2015-08-12 11:50:07 +08:00
parent 5241f6a472
commit f8f1fd292c

View File

@ -15,6 +15,10 @@ function defaultResolve(data) {
return data || [];
}
function getColumnKey(col, index) {
return col.key || col.dataIndex || index;
}
class DataSource {
init(config) {
this.config = config;
@ -113,23 +117,6 @@ var AntTable = React.createClass({
let sortColumn = this.state.sortColumn;
let sortOrder = this.state.sortOrder;
let sorter;
//
if (sortColumn) {
sortColumn.className = '';
}
if (sortColumn !== column) { //
sortOrder = order;
sortColumn = column;
sortColumn.className = 'ant-table-column-sort';
} else { //
if (sortOrder === order) { //
sortOrder = '';
sortColumn = null;
} else { //
sortOrder = order;
sortColumn.className = 'ant-table-column-sort';
}
}
if (this.isLocalDataSource()) {
sorter = function () {
let result = column.sorter.apply(this, arguments);
@ -261,7 +248,7 @@ var AntTable = React.createClass({
},
renderColumnsDropdown(columns) {
return columns.map((column) => {
return columns.map((column, i) => {
column = objectAssign({}, column);
let key = this.getColumnKey(column);
let filterDropdown, menus, sortButton;
@ -280,7 +267,12 @@ var AntTable = React.createClass({
</Dropdown>;
}
if (column.sorter) {
let isSortColumn = (this.state.sortColumn === column);
var colKey = getColumnKey(column, i);
let isSortColumn = (getColumnKey(this.state.sortColumn, i) === colKey);
if (isSortColumn) {
column.className = column.className || '';
column.className += ' ant-table-column-sort';
}
sortButton = <div className="ant-table-column-sorter">
<span className={'ant-table-column-sorter-up ' +
((isSortColumn && this.state.sortOrder === 'ascend') ? 'on' : 'off')}