Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wanjj_1210
ant-design
提交
7ba8e08b
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,发现更多精彩内容 >>
提交
7ba8e08b
编写于
8月 05, 2015
作者:
dqaria
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加入Table 远程模式支持由外界发起请求方法
上级
902ca1dc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
105 addition
and
7 deletion
+105
-7
components/table/demo/advance-ajax.md
components/table/demo/advance-ajax.md
+76
-0
components/table/demo/nopagination.md
components/table/demo/nopagination.md
+1
-1
components/table/index.jsx
components/table/index.jsx
+28
-6
未找到文件。
components/table/demo/advance-ajax.md
0 → 100644
浏览文件 @
7ba8e08b
# 外界触发表格刷新
-
order: 8
查询页面大量使用表格,当删除某条目后需要刷新。可直接传入DataSource实例,然后调用其fetch方法刷新表格。
**注意,请打开console调试fetch方法**
---
````
jsx
var
Table
=
antd
.
Table
;
var
DataSource
=
Table
.
DataSource
;
var
columns
=
[{
title
:
'
姓名
'
,
dataIndex
:
'
name
'
,
filters
:
[{
text
:
'
姓李的
'
,
value
:
'
李
'
},
{
text
:
'
姓胡的
'
,
value
:
'
胡
'
}]
},
{
title
:
'
年龄
'
,
dataIndex
:
'
age
'
,
sorter
:
true
},
{
title
:
'
住址
'
,
dataIndex
:
'
address
'
}];
function
resolve
(
result
)
{
return
result
.
data
;
}
var
dataSource
=
new
DataSource
({
url
:
"
/components/table/demo/data.json
"
,
resolve
:
function
(
result
)
{
return
result
.
data
;
},
// 和后台接口返回的分页数据进行适配
getPagination
:
function
(
result
)
{
return
{
total
:
result
.
totalCount
,
pageSize
:
result
.
pageSize
}
},
// 和后台接口接收的参数进行适配
// 参数里提供了分页、筛选、排序的信息
getParams
:
function
(
pagination
,
filters
,
sorter
)
{
console
.
log
(
'
getParams 的参数是:
'
,
pagination
,
filters
,
sorter
);
var
params
=
{
pageSize
:
pagination
.
pageSize
,
currentPage
:
pagination
.
current
,
sortField
:
sorter
.
field
,
sortOrder
:
sorter
.
order
};
for
(
let
key
in
filters
)
{
params
[
key
]
=
filters
[
key
];
}
console
.
log
(
'
请求参数:
'
,
params
);
return
params
;
}
});
// 可供外部调用fetch接口刷新表格
dataSource
.
fetch
();
// 请打开console调试fetch方法
window
.
dataSource
=
dataSource
;
React
.
render
(<
Table
columns
=
{
columns
}
dataSource
=
{
dataSource
}
/>
,
document
.
getElementById
(
'
components-table-demo-advance-ajax
'
));
````
components/table/demo/nopagination.md
浏览文件 @
7ba8e08b
# 不显示分页
-
order:
8
-
order:
9
传入 pagination 为 false 即可。
...
...
components/table/index.jsx
浏览文件 @
7ba8e08b
...
...
@@ -15,7 +15,17 @@ function defaultResolve(data) {
return
data
||
[];
}
export
default
React
.
createClass
({
class
DataSource
{
constructor
(
config
)
{
this
.
url
=
config
.
url
||
""
;
this
.
resolve
=
config
.
resolve
||
defaultResolve
;
this
.
getParams
=
config
.
getParams
||
noop
;
this
.
getPagination
=
config
.
getPagination
||
noop
;
this
.
fetch
=
noop
;
}
}
var
AntTable
=
React
.
createClass
({
getInitialState
()
{
return
{
// 减少状态
...
...
@@ -75,11 +85,19 @@ export default React.createClass({
},
getRemoteDataSource
()
{
return
objectAssign
({
resolve
:
defaultResolve
,
getParams
:
noop
,
getPagination
:
noop
},
this
.
props
.
dataSource
);
// 判断传入DataSource类型
var
dataSource
=
this
.
props
.
dataSource
;
if
(
dataSource
.
constructor
===
DataSource
)
{
// 当传入 dataSource Instance 时,对外部DataSource暴露fetch接口
dataSource
.
fetch
=
this
.
fetch
;
return
dataSource
;
}
else
{
return
objectAssign
({
resolve
:
defaultResolve
,
getParams
:
noop
,
getPagination
:
noop
},
this
.
props
.
dataSource
);
}
},
toggleSortOrder
(
order
,
column
)
{
...
...
@@ -450,3 +468,7 @@ export default React.createClass({
</
div
>;
}
});
AntTable
.
DataSource
=
DataSource
;
export
default
AntTable
;
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录