Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote data source support #73

Closed
luqin opened this issue Oct 14, 2015 · 16 comments
Closed

Remote data source support #73

luqin opened this issue Oct 14, 2015 · 16 comments

Comments

@luqin
Copy link
Contributor

luqin commented Oct 14, 2015

function dataSource(query){
    //you need to return a Promise (or a thenable)
    return $.ajax('http://5.101.99.47:8090/5000?pageSize=' + query.pageSize + '&skip=' + query.skip)
    //of course you can also send a POST request
}
module.exports = React.createClass({

    render: function(){
        return <DataTable
            dataSource={dataSource}
        />
    }
})
@AllenFang
Copy link
Owner

I dont want to support this feature in near future. I want to fix bugs and enhance function currently. So about fetching remote data, I think you should do it in your web util module or something like that, and feed the data in react-bootstrap-table. So if I support these query parameter which like you post on #72. you can get your remote base on these query parameter. So I will leave this issue until I have free time to do this stuff :)

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

我现在正在实现这个功能,请问如何设计api比较合适?

@AllenFang
Copy link
Owner

HI @luqin, currently, I've no idea about that ;( and in near future, I dont have idea to solve this issues.

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

可以参考下这个 Table:
demo:http://ant.design/components/table/
source:https://github.com/ant-design/ant-design/blob/master/components/table/index.jsx

不过 DataSource 提供成这样更好: http://zippyui.com/react-datagrid/#/examples/remote-data-source-with-jquery
这样不用内置 ajax

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

提供基于 promise 方式的 DataSource 接口如何?
这样我们取数据时可以 dataSource(info).then()...
这样我们可以支持任意的获取数据方式,不仅仅局限于 remote data

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

  • like DataTables
function dataSource(info, callback) {

}
  • base on promise
function dataSource(info) {
    return $.ajax(...).then(doSomthing);
}
function dataSource(info) {
    return fetch(...);
}

或者是我们同时支持两种方式

@AllenFang
Copy link
Owner

I have a basic claim : Just don't modify the origin design as fully as possible. So, how about separate the loading data in local and remote, I means if use DataSource, just definitely he want to load data from remote not local.

@AllenFang
Copy link
Owner

http://zippyui.com/react-datagrid/#/examples/remote-data-source-with-jquery

Thanks, It's a best solution for our requirement, how do you thinks?

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

这种方式呢?http://ant.design/components/table/

分为 local 和 remote 两种方式,我感觉 local 时 DataSet 没有作用,直接 setState render 数据就够了。

@luqin
Copy link
Contributor Author

luqin commented Oct 19, 2015

另外我觉得 insert Row 还有 toast 完全没有必要,我们另外需要的是 remote 取数据时的 loading 状态。

@AllenFang
Copy link
Owner

http://ant.design/components/table/ >> it's ok
About insertRow, I think it should be preserve and dont do any modify, if you use remote fetch data, you can disable insertRow, there's no any conflict.

About toastr, it's a PR add react-toastr in this component, just to perform some alarm if data be updated or insert. If you want to remove it, I thinks it's ok, but you need give some alternative solution for "showing alarm".

@luqin
Copy link
Contributor Author

luqin commented Oct 23, 2015

能不能将警告提供回调给用户,让用户决定警告的展示方式?我们默认用console控制台。你觉得如何?

@AllenFang
Copy link
Owner

I thinks it's ok and is good feature, but we need to provide the default alarm for user, so you can add this customize alarm to react-bootstrap-table but don't remove origin one.

@luqin
Copy link
Contributor Author

luqin commented Oct 23, 2015

另外css能不能提供更多的选择?

  • react-bootstrap-table-all.css 包含 toastr css
  • react-bootstrap-table.css 不包含 toastr css

@AllenFang
Copy link
Owner

Good

@AllenFang
Copy link
Owner

Support on remote data, check this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants