fiduswriter / simple-datatables

DataTables but in TypeScript transpiled to Vanilla JS
Other
1.42k stars 254 forks source link

Support AJAX/Pagination+Search+Sort #386

Open tacman opened 5 months ago

tacman commented 5 months ago

I understand how to use insert() in order to add new rows, which works great when I simply want to load a bunch of data remotely.

But if the data is big it can become slow, so obviously I can just load part of that data. But then the datatable is only showing the partial data, and the pagination is related to the partial data.

If the library had a way to know the maximum number of items, the pagination could be based on that number, rather than the number of actual items. Of course, if someone clicked on a page (or sort, filter, etc.), it would need to make a callback to properly fetch the data.

I realize this isn't trivial, but would be a cool feature.

johanneswilm commented 3 months ago

@tacman I agree, that would be a nice addition. However, with a lot of the data not being available, the table cannot really do a lot of calculations, for example how wide a specific column should be given some settings, etc. .

tacman commented 3 months ago

Makes sense. it could default to treating the first X number of rows (from the ajax source) as if the data were in the HTML. Or allow the developers to set those attributes. Just brainstorming.

walirt commented 2 months ago

any news?

johanneswilm commented 2 months ago

@walirt Will you implement it? I have no use for such a feature personally.

walirt commented 2 months ago

@walirt Will you implement it? I have no use for such a feature personally.

This is a common function of the data table, we generally do not return all the data from the api, but paging to return data