Add models-table-server-paginated component #62
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While models-table works great for certain amounts of data, it cannot work with server-side paginated data. In order to make this possible, I added a second component,
models-table-server-paginated
, which makes this scenario possible.This component extends the base
models-table
component. For the end user, it can be used (nearly) the same:It expects
myData
to be an ember-data query, eg:It will then take this query and extend it with pagination, sorting and filtering information. All other query parameters added in will remain untouched. Everything else works exactly the same - global filters, column filters etc. still use the same properties to control them. A few things to notice:
filterWithSelect
for a column, you must usepredefinedFilterOptions
, because the automatic loading of possible filter values cannot work here.filteredBy
for columns, which works much likesortedBy
: if set, this field will be used as query parameter, otherwise it will use thepropertyName
.sortedBy: false
on a column, sorting will be disabled for this column.There are a couple of things which can be configured to adapt to your API:
This default configuration would try to get the total page count from
model.get('meta.pagesCount')
and the total item count frommodel.get('meta.itemsCount')
, and would then go on to build the following query: