简体   繁体   English

ReactJS 可过滤、可排序的表格

[英]ReactJS filterable, sortable tables

In my component's state there is a 'contributors' array.在我的组件状态中,有一个“贡献者”数组。 Each element of this array is an object with some properties.这个数组的每个元素都是一个具有一些属性的对象。 I want to display them in a table.我想在表格中显示它们。 And I want to have an ability to sort and filter it.我希望能够对它进行排序和过滤。 So Eg:所以例如:

 <table> <tr> <th>Name</th> <th>Contributions</th> <th>Followers</th> <th>Repos</th> <th>Gists</th> </tr> <tr> <td>Peter</td> <td>3000</td> <td>12</td> <td>30</td> <td>30</td> </tr> <tr> <td>George</td> <td>200</td> <td>0</td> <td>1</td> <td>1</td> </tr> <tr> <td>Stephanie</td> <td>333</td> <td>2</td> <td>2</td> <td>2</td> </tr> <tr> <td>Caroline</td> <td>333</td> <td>2</td> <td>100</td> <td>100</td> </tr> <tr> <td>Paul</td> <td>5</td> <td>5</td> <td>3</td> <td>3</td> </tr> <tr> <td>Adam</td> <td>9001</td> <td>33333</td> <td>22</td> <td>22</td> </tr> </table>
The date is taken from the state which is taken from the API response. 日期取自 API 响应中的状态。 I would like to have the ability to sort it alphabetically (az, za), and by each of the numbers (contributions, followers, repos, gists - biggest to smallest, smallest to biggest). 我希望能够按字母顺序(az,za)和每个数字(贡献,关注者,回购,要点 - 从最大到最小,最小到最大)对其进行排序。 And filter it by amount. 并按数量过滤。 I was looking for a library that does this for me but to no avail. 我正在寻找一个为我做这件事的图书馆,但无济于事。 How can I implement that? 我该如何实施?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM