Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
e982ab46
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,发现更多精彩内容 >>
提交
e982ab46
编写于
7月 13, 2015
作者:
A
afc163
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
improve filter
上级
9440eb78
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
15 deletion
+66
-15
components/table/demo/filter.md
components/table/demo/filter.md
+3
-3
components/table/index.jsx
components/table/index.jsx
+38
-11
style/components/dropdown.less
style/components/dropdown.less
+15
-0
style/components/select.less
style/components/select.less
+1
-1
style/components/table.less
style/components/table.less
+9
-0
未找到文件。
components/table/demo/filter.md
浏览文件 @
e982ab46
...
...
@@ -23,9 +23,9 @@ var columns = [{
value
:
'
value2
'
}];
},
onFilter
:
function
(
key
)
{
console
.
log
(
key
);
this
.
fetch
(
this
.
props
.
dataSource
+
'
?age=
'
+
key
);
onFilter
:
function
(
filters
)
{
console
.
log
(
filters
);
this
.
fetch
(
this
.
props
.
dataSource
+
'
?age=
'
+
filters
.
join
(
'
,
'
)
);
}
},
{
title
:
'
地址
'
,
...
...
components/table/index.jsx
浏览文件 @
e982ab46
...
...
@@ -11,6 +11,7 @@ let AntTable = React.createClass({
return
{
selectedRowKeys
:
[],
loading
:
false
,
filters
:
[],
data
:
[]
};
},
...
...
@@ -24,9 +25,7 @@ let AntTable = React.createClass({
},
renderMenus
(
items
)
{
let
menuItems
=
items
.
map
((
item
)
=>
{
return
<
Menu
.
Item
key
=
{
item
.
value
}
>
{
item
.
text
}
</
Menu
.
Item
>;
return
<
Menu
.
Item
key
=
{
item
.
value
}
>
{
item
.
text
}
</
Menu
.
Item
>;
});
return
menuItems
;
},
...
...
@@ -40,9 +39,21 @@ let AntTable = React.createClass({
column
.
sorter
.
call
(
this
,
column
.
sortOrder
);
}
},
onSelectFilter
()
{
handleFilter
(
column
)
{
if
(
column
.
onFilter
)
{
column
.
onFilter
.
call
(
this
,
column
.
filters
);
}
},
handleSelectFilter
(
column
,
selected
)
{
column
.
filters
=
column
.
filters
||
[];
column
.
filters
.
push
(
selected
);
},
onDeselectFilter
()
{
handleDeselectFilter
(
column
,
key
)
{
column
.
filters
=
column
.
filters
||
[];
var
index
=
column
.
filters
.
indexOf
(
key
);
if
(
index
!==
-
1
)
{
column
.
filters
.
splice
(
index
,
1
);
}
},
renderColumnsDropdown
()
{
this
.
props
.
columns
=
this
.
props
.
columns
.
map
((
column
)
=>
{
...
...
@@ -51,14 +62,30 @@ let AntTable = React.createClass({
}
let
filterDropdown
,
menus
,
sortButton
;
if
(
column
.
filter
)
{
menus
=
<
Menu
multiple
=
{
true
}
onSelect
=
{
this
.
onSelectFilter
}
onDeselect
=
{
this
.
onDeselectFilter
}
>
menus
=
<
Menu
multiple
=
{
true
}
className
=
"ant-table-filter-dropdown"
onSelect
=
{
this
.
handleSelectFilter
.
bind
(
this
,
column
)
}
onDeselect
=
{
this
.
handleDeselectFilter
.
bind
(
this
,
column
)
}
>
{
this
.
renderMenus
(
column
.
filter
())
}
<
button
className
=
"ant-btn ant-btn-primary ant-btn-sm"
onClick
=
{
column
.
onFilter
.
bind
(
this
)
}
>
确 定
</
button
>
<
Menu
.
Item
disabled
>
<
button
style
=
{
{
cursor
:
'
pointer
'
,
pointerEvents
:
'
visible
'
}
}
className
=
"ant-btn ant-btn-primary ant-btn-sm"
onClick
=
{
this
.
handleFilter
.
bind
(
this
,
column
)
}
>
确 定
</
button
>
</
Menu
.
Item
>
</
Menu
>;
filterDropdown
=
<
Dropdown
trigger
=
"click"
closeOnSelect
=
{
false
}
overlay
=
{
menus
}
>
<
i
className
=
"anticon anticon-bars"
></
i
>
let
dropdownSelectedClass
=
''
;
if
(
column
.
filters
&&
column
.
filters
.
length
>
0
)
{
dropdownSelectedClass
=
'
ant-table-filter-selected
'
;
}
filterDropdown
=
<
Dropdown
trigger
=
"click"
closeOnSelect
=
{
false
}
overlay
=
{
menus
}
>
<
i
title
=
"筛选"
className
=
{
'
anticon anticon-bars
'
+
dropdownSelectedClass
}
></
i
>
</
Dropdown
>;
}
if
(
column
.
sorter
)
{
...
...
style/components/dropdown.less
浏览文件 @
e982ab46
...
...
@@ -65,6 +65,7 @@
font-weight: normal;
color: #666;
white-space: nowrap;
cursor: pointer;
a {
color: #666;
...
...
@@ -103,6 +104,20 @@
background-color: #e5e5e5;
line-height: 0;
}
&-selected {
background-color: tint(@primary-color, 90%);
position: relative;
&:after {
content: '\e613';
font-family: 'anticon';
font-weight: bold;
position: absolute;
top: 6px;
right: 16px;
color: @primary-color;
}
}
}
}
}
...
...
style/components/select.less
浏览文件 @
e982ab46
...
...
@@ -249,7 +249,7 @@
cursor: pointer;
&:hover, &-active, &-selected {
background-color:
rgba(142, 200, 249, 0.1
) !important;
background-color:
tint(@primary-color, 90%
) !important;
}
&-selected {
...
...
style/components/table.less
浏览文件 @
e982ab46
...
...
@@ -31,6 +31,14 @@
color: #666;
}
}
.@{tablePrefixClass}-filter-dropdown {
min-width: 88px;
}
.@{tablePrefixClass}-filter-selected.anticon-bars {
color: @primary-color;
}
}
td {
...
...
@@ -61,6 +69,7 @@
background: #fff;
border-bottom: 1px solid #e9e9e9;
}
td {
padding: 6px 8px;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录