tochoromero / aurelia-table

Simple functional data table for Aurelia
https://tochoromero.github.com/aurelia-table
MIT License
67 stars 25 forks source link

Remote paging? #10

Closed don-bluelinegrid closed 8 years ago

don-bluelinegrid commented 8 years ago

Hector,

I'm taking a look at your component to possibly use in a new commercial product.

I am planning to do remote paging - where the grid would emit an event for each page request, which would be translated to a remote fetch request with parameters for the offset, pageSize, etc. But it looks like your component expects a total dataset collection to be initially loaded for paging in the client only.

Can you provide any advice about using your component in a remote-paging application, or whether you think this would be straightforward/possible to do?

Thanks, Don

tochoromero commented 8 years ago

Hello Don. Thank you for looking into my plugin, it is exciting to know that other people think this is useful.

I have been thinking a lot about adding remote datasources capabilities into Aurelia Table, but I'm really not completely sure on the right way to tackle it. What you want to achieve is completely doable with the current Table Features. I will definitely take the time to add a section into the documentation explaining how server side pagination can be achieved. In the meanwhile the way try to explain how I would do it:

Aurelia Table doesn't really expect a fully populated array from the get go. You can provide an empty array and perform a remote fetch to get the data. Once you set the new data into the Array Aurelia Table will automatically update and reflect the changes.

Because Aurelia Table automatically updates when you change the data array, you can perform your fetch queries with your offset and pageSize and then just set the result in the array.

As for the pagination controllers you can provide your own or use the one Aurelia Table ships with (just don't wire it into the actual table). When the user clicks on a page, you will go and perform the remote fetch and set the results in the data array.

There is caveat though, Sorting and Filtering will be limited to the current page, and this can be a deal breaker. With the current features global sorting and filtering with a remote datasource is not possible. I will evaluate the possibility to add remote data source capabilities, but it is hard to get it right when you are doing it on a generic way.

Please let me know if this information is useful; and if you have any ideas on how to tackle this issue I'm all ears.

Cheers. Hector Romero

tochoromero commented 8 years ago

I'm open to including this, but I'm having a hard time figuring out the right way to do it. I can provide a method that gives you the current page, the page size, the filters and the sorting columns with a direction. Then the method needs to return a collection with the results and we need a way to let the table know how many items we have in total, with the current filters, or at least if we are in the last page.

Writing this on a generic way will put a LOT of work into the backend, but I guess there is no way around that.

Please if you have some concrete ideas on how to implement this reopen the issue with details.

arnonuem commented 5 years ago

I would like to see the same improvement there.

When i call my REST service i get the following pagination information along with the data. { data: ..., page: { size: 10, totalElements: 2, totalPages: 1, number: 0 } }

What i need now is to update these properties to the table on each request. Also the next button or a button on a number of the pager should modify my request parameters like: /.../.../?page=1&size=10

How can i attach my requests to the pager? How do i interact with the pager with the paging data shown above?

Maybe you can find some additional information here: https://aurelia-ui-toolkits.github.io/demo-kendo/#/samples/grid-binding-to-remote-data

Or please take a look into: https://github.com/tochoromero/aurelia-table/pull/36