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

关于table的问题 #113

Open
zhangqhzz opened this issue May 4, 2018 · 5 comments
Open

关于table的问题 #113

zhangqhzz opened this issue May 4, 2018 · 5 comments

Comments

@zhangqhzz
Copy link

table组件使用fetch参数是可以得到数据,但我的分页数据每次都是从后台取,而不是一次性取出来,这个怎么处理?

@zhangqhzz
Copy link
Author

实际上Table中的filter sort均是需要向后台请求的,目前的Table只能一次性取出全部数据然后再处理

@Lobos
Copy link
Owner

Lobos commented May 4, 2018

不用内置的分页,用Pagination组件。

@zhangqhzz
Copy link
Author

不知如何用,因为Table组件是compose(
Fetch(true),
Filter,
Sort,
Pagination
)(Table)的,都内置了

@zhangqhzz
Copy link
Author

在使用Table组件时,不设置pagination,然后在Table下加<Pagination .../>吗? 这样没有组合的来得方便了

@Lobos
Copy link
Owner

Lobos commented May 4, 2018

嗯,是这样的,因为每个业务涉及到分页的情况都不一样,所以不好做成通用的组件。复用的话,自己外面在封装一层就可以了。大概类似这样。

class CustomTable extends Component {
  constructor(props) {
    // ...
    this.state = { page = 1, size = 20 }
  }

  componentDidMount() {
    this.fetch()
  } 

  fetch() {
    // fetch data
    const { page, size } = this.state
    fetch(this.props.baseUrl, {page,size}).then(...)
  }

  handlePageChange() {
     this.setState({...},  this.fetch)
  }

  render() {
    <Table />
    <Pagination />
  }
}

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

No branches or pull requests

2 participants