Browse Source

Feature: support paging columns, ref #708

pull/911/head
afc163 9 years ago
parent
commit
b855525615
  1. 48
      components/table/demo/paging-columns.md
  2. 4
      components/table/index.jsx
  3. 56
      style/components/table.less

48
components/table/demo/paging-columns.md

@ -0,0 +1,48 @@
# 滚屏分页的列
- order: 16
对于列数很多的数据,可以进行横向的分页,通过切换符切换当前展现的列。
---
````jsx
import { Table } from 'antd';
const columns = [
{ title: '姓名', dataIndex: 'name', key: 'name' },
{ title: '年龄', dataIndex: 'age', key: 'age' },
{ title: '列1', dataIndex: 'age', key: '1' },
{ title: '列2', dataIndex: 'age', key: '2' },
{ title: '列3', dataIndex: 'age', key: '3' },
{ title: '列4', dataIndex: 'age', key: '4' },
{ title: '列5', dataIndex: 'age', key: '5' },
{ title: '列6', dataIndex: 'age', key: '6' },
{ title: '列7', dataIndex: 'age', key: '7' },
{ title: '列8', dataIndex: 'age', key: '8' },
{
title: '操作',
key: 'operation',
render() {
return <a href="#">操作</a>;
}
},
];
const data = [{
key: '1',
name: '胡彦斌',
age: 32,
}, {
key: '2',
name: '胡彦祖',
age: 42,
}];
const App = React.createClass({
render() {
return <Table columns={columns} dataSource={data} columnsPageRange={[2, 9]} columnsPageSize={4} />;
}
});
ReactDOM.render(<App />, mountNode);
````

4
components/table/index.jsx

@ -438,11 +438,11 @@ let AntTable = React.createClass({
);
}
column.title = (
<div>
<span>
{column.title}
{sortButton}
{filterDropdown}
</div>
</span>
);
return column;
});

56
style/components/table.less

@ -1,7 +1,7 @@
@import "../mixins/index";
@table-prefix-cls: ~"@{css-prefix}table";
@table-border-color: #e9e9e9;
@table-border-color: @border-color-split;
@table-head-background-color: #f4f4f4;
.@{table-prefix-cls} {
@ -25,6 +25,7 @@
background: @table-head-background-color;
font-weight: bold;
transition: background .3s ease;
position: relative;
.anticon-filter {
margin-left: 4px;
@ -107,14 +108,14 @@
&-small {
table {
border: 1px solid #e9e9e9;
border: 1px solid @border-color-split;
padding: 0 8px;
}
th {
padding: 10px 8px;
background: #fff;
border-bottom: 1px solid #e9e9e9;
border-bottom: 1px solid @border-color-split;
}
td {
@ -163,11 +164,11 @@
&.@{table-prefix-cls}-bordered {
table {
border: 1px solid #e9e9e9;
border: 1px solid @border-color-split;
}
th {
border-bottom: 1px solid #e9e9e9;
border-bottom: 1px solid @border-color-split;
}
tr:last-child {
@ -179,7 +180,7 @@
th,
td {
border-right: 1px solid #e9e9e9;
border-right: 1px solid @border-color-split;
&:last-child {
border-right: 0;
}
@ -201,7 +202,7 @@
text-align: center;
font-size: 12px;
color: #999;
border-bottom: 1px solid #e9e9e9;
border-bottom: 1px solid @border-color-split;
position: absolute;
top: 50px;
left: 0;
@ -286,7 +287,7 @@
height: 18px;
text-align: center;
line-height: 15px;
border: 1px solid #e9e9e9;
border: 1px solid @border-color-split;
user-select: none;
background: #fff;
&-cell {
@ -319,4 +320,43 @@
.@{table-prefix-cls}-row-indent + .@{table-prefix-cls}-row-expand-icon {
margin-right: 8px;
}
&-column-hidden {
display: none;
}
&-prev-columns-page,
&-next-columns-page {
cursor: pointer;
color: #666;
z-index: 1;
&:hover {
color: @primary-color;
}
&-disabled {
cursor: not-allowed;
color: #bbb;
&:hover {
color: #bbb;
}
}
}
&-prev-columns-page {
position: absolute;
left: -8px;
&:before {
content: '\e601';
.iconfont-size-under-12px(9px);
font-weight: bold;
font-family: anticon;
}
}
&-next-columns-page {
float: right;
&:before {
content: '\e600';
.iconfont-size-under-12px(9px);
font-weight: bold;
font-family: anticon;
}
}
}

Loading…
Cancel
Save