Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
998fa881
A
ant-design
项目概览
wanjj_1210
/
ant-design
与 Fork 源项目一致
从无法访问的项目Fork
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
ant-design
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
998fa881
编写于
11月 24, 2015
作者:
B
Benjy Cui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: Table should support i18n
上级
51a2798e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
86 addition
and
9 deletion
+86
-9
components/table/demo/locale.md
components/table/demo/locale.md
+65
-0
components/table/filterDropdown.jsx
components/table/filterDropdown.jsx
+4
-4
components/table/index.jsx
components/table/index.jsx
+16
-5
components/table/index.md
components/table/index.md
+1
-0
未找到文件。
components/table/demo/locale.md
0 → 100644
浏览文件 @
998fa881
# 国际化
-
order: 15
用
`locale`
设置表格的排序、过滤按钮的文字或
`title`
。
---
````
jsx
import
{
Table
}
from
'
antd
'
;
const
columns
=
[{
title
:
'
Name
'
,
dataIndex
:
'
name
'
,
filters
:
[{
text
:
'
Starts with A
'
,
value
:
'
^[aA]
'
},
{
text
:
'
Starts with B
'
,
value
:
'
^[bB]
'
}],
onFilter
:
function
(
value
,
record
)
{
return
new
RegExp
(
value
).
test
(
record
.
name
);
},
},
{
title
:
'
Age
'
,
dataIndex
:
'
age
'
,
sorter
:
function
(
a
,
b
)
{
return
a
.
age
-
b
.
age
;
}
},
{
title
:
'
Address
'
,
dataIndex
:
'
address
'
}];
const
data
=
[{
key
:
'
1
'
,
name
:
'
Alice
'
,
age
:
32
,
address
:
'
Somewhere
'
},
{
key
:
'
2
'
,
name
:
'
Bob
'
,
age
:
42
,
address
:
'
Somewhere
'
},
{
key
:
'
3
'
,
name
:
'
Candy
'
,
age
:
32
,
address
:
'
Somewhere
'
}];
const
locale
=
{
sortAscend
:
'
Sort ascending
'
,
sortDescend
:
'
Sort descending
'
,
filterTitle
:
'
Filter
'
,
filterConfirm
:
'
Confirm
'
,
filterReset
:
'
Reset
'
};
ReactDOM
.
render
(
<
Table
columns
=
{
columns
}
dataSource
=
{
data
}
locale
=
{
locale
}
/>,
document
.
getElementById
(
'
components-table-demo-locale
'
)
);
````
components/table/filterDropdown.jsx
浏览文件 @
998fa881
...
...
@@ -48,7 +48,7 @@ let FilterMenu = React.createClass({
return
menuItems
;
},
render
()
{
let
column
=
this
.
props
.
column
;
let
{
column
,
locale
}
=
this
.
props
;
// default multiple selection in filter dropdown
let
multiple
=
true
;
if
(
'
filterMultiple
'
in
column
)
{
...
...
@@ -69,7 +69,7 @@ let FilterMenu = React.createClass({
pointerEvents
:
'
visible
'
}
}
onClick
=
{
this
.
handleConfirm
}
>
确定
{
locale
.
filterConfirm
}
</
a
>
<
a
className
=
"ant-table-filter-dropdown-link clear"
style
=
{
{
...
...
@@ -77,7 +77,7 @@ let FilterMenu = React.createClass({
pointerEvents
:
'
visible
'
}
}
onClick
=
{
this
.
handleClearFilters
}
>
重置
{
locale
.
filterReset
}
</
a
>
</
Menu
.
Item
>
</
Menu
>;
...
...
@@ -92,7 +92,7 @@ let FilterMenu = React.createClass({
visible
=
{
this
.
state
.
visible
}
onVisibleChange
=
{
this
.
onVisibleChange
}
closeOnSelect
=
{
false
}
>
<
Icon
title
=
"筛选"
type
=
"bars"
className
=
{
dropdownSelectedClass
}
/>
<
Icon
title
=
{
locale
.
filterTitle
}
type
=
"bars"
className
=
{
dropdownSelectedClass
}
/>
</
Dropdown
>;
}
});
...
...
components/table/index.jsx
浏览文件 @
998fa881
...
...
@@ -16,6 +16,15 @@ function defaultResolve(data) {
return
data
||
[];
}
const
defaultLocale
=
{
sortAscend
:
'
升序排序
'
,
sortDescend
:
'
降序排序
'
,
filterTitle
:
'
筛选
'
,
filterConfirm
:
'
确定
'
,
filterReset
:
'
重置
'
};
class
DataSource
{
init
(
config
)
{
this
.
config
=
config
;
...
...
@@ -69,8 +78,8 @@ let AntTable = React.createClass({
size
:
'
default
'
,
loading
:
false
,
bordered
:
false
,
onChange
:
function
()
{
}
onChange
:
noop
,
locale
:
{
}
};
},
...
...
@@ -398,6 +407,7 @@ let AntTable = React.createClass({
},
renderColumnsDropdown
(
columns
)
{
let
locale
=
objectAssign
({},
defaultLocale
,
this
.
props
.
locale
);
return
columns
.
map
((
column
,
i
)
=>
{
column
=
objectAssign
({},
column
);
let
key
=
this
.
getColumnKey
(
column
,
i
);
...
...
@@ -405,7 +415,7 @@ let AntTable = React.createClass({
if
(
column
.
filters
&&
column
.
filters
.
length
>
0
)
{
let
colFilters
=
this
.
state
.
filters
[
key
]
||
[];
filterDropdown
=
<
FilterDropdown
column
=
{
column
}
<
FilterDropdown
locale
=
{
locale
}
column
=
{
column
}
selectedKeys
=
{
colFilters
}
confirmFilter
=
{
this
.
handleFilter
}
/>;
}
...
...
@@ -417,16 +427,17 @@ let AntTable = React.createClass({
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
'
)
}
title
=
"升序排序"
title
=
{
locale
.
sortAscend
}
onClick
=
{
this
.
toggleSortOrder
.
bind
(
this
,
'
ascend
'
,
column
)
}
>
<
Icon
type
=
"caret-up"
/>
</
span
>
<
span
className
=
{
'
ant-table-column-sorter-down
'
+
((
isSortColumn
&&
this
.
state
.
sortOrder
===
'
descend
'
)
?
'
on
'
:
'
off
'
)
}
title
=
"降序排序"
title
=
{
locale
.
sortDescend
}
onClick
=
{
this
.
toggleSortOrder
.
bind
(
this
,
'
descend
'
,
column
)
}
>
<
Icon
type
=
"caret-down"
/>
</
span
>
...
...
components/table/index.md
浏览文件 @
998fa881
...
...
@@ -72,6 +72,7 @@ var dataSource = new Table.DataSource({
| expandIconAsCell | 设置展开 Icon 是否单独一列 | Boolean | | true |
| onChange | 分页、排序、筛选变化时触发 | Function(pagination, filters, sorter) | | |
| loading | 页面是否加载中 | Boolean | | false |
| locale | 设置排序、过滤按钮的文字或
`title`
| Object | |
[
默认值
](
https://github.com/ant-design/ant-design/issues/575#issuecomment-159169511
)
|
### Column
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录