wenzhixin / bootstrap-table-examples

Bootstrap table examples
https://examples.bootstrap-table.com/
MIT License
2.24k stars 1.62k forks source link

Feature-request: server-side pagination for dynamic(/changing) data #450

Open hepcat72 opened 2 years ago

hepcat72 commented 2 years ago

I was trying to figure out how to enable server-side pagination for my implementation of bootstrap-table for very large tables (hundreds of thousands of rows) that are a part of an advanced search page. The data is the result of a complex search query (using ands and ors, e.g.: tissue is brain and (compound is lysine or compound is glucose)). The search parameters are stored in a JSON object which is passed to the server via a form. The actual query on the server (for queries resulting in large data sets) takes a relatively long time. My hope was that bootstrap-table's server-side pagination would allow me to pass in a limit and an offset that I could use in the query (as well as the sort field and sort direction) so that I could shorten the query time as well as the rendering time.

When I was trying to figure out what I needed to do to implement the server-side pagination that bootstrap table provides, I really didn't know what to expect, but I was looking for how to pass in the limit, the offset, the sort field, and the sort direction (asc or desc). I found the data-url, but none of the examples demonstrated how to send the limit and offset (let alone the sort field and sort direction), so I figured I would skip the query speed improvement for now and settle for the rendering speed improvement (since I'd already implemented caching to improve the query speed).

However, I quickly realized that I also had no way to pass in the JSON-ized search parameters from the client to the data URL in order to retrieve all the data either. I presume that the data-url is assumed to be either a static flat file or a request for data that doesn't change.

The only mechanism I can figure I could use to get the data would be to implement some javascript for the onSort and onPageChange events in order to query the server using a POST to retrieve what I need for each page. (However, I'm not even sure how to decorate the contents of the table the way I currently do using a django template. But since it seems like I cannot get server-side pagination to do what I need, I feel like it might be overall easier to use Django's pagination features so I don't have to reimplement the template...).

So this feature request is to provide a way to set a POST data-url along with values to send in the post. In my case, all I want to send is my JSON-ized search query. But I would also need an example that will show me what the form elements for limit, offset, sort_field, and sort_direction are named and what to expect their values to be (e.g. sort_direction will be either ASC or DESC). Presumably, sort_field would be whatever we set as the data-field and the limit and offset would be starting row number (as opposed to page number) and number of rows per page.

smillove commented 2 years ago

这是一封自动回复邮件。已经收到您的来信,我会尽快回复。