Components.ModelsTableServerPaginated Class
Table-component with pagination, sorting and filtering.
It should be used when pagination, filtering and sorting are done on the server-side. Otherwise models-table should be used.
This component extends the base models-table component. For the end user, it can be used (nearly) the same:
{{models-table-server-paginated data=data columns=columns}}
Usage with block context:
{{#models-table-server-paginated data=data columns=columns as |mt|}}
{{mt.global-filter}}
{{mt.columns-dropdown}}
{{mt.table}}
{{mt.footer}}
{{/models-table}}
ModelsTableServerPaginated yields references to the following contextual components:
- models-table/global-filter - global filter used for table data
- models-table/columns-dropdown - dropdown with list of options to toggle columns and column-sets visibility
- models-table/table - table with a data
- models-table/footer - summary and pagination
Check own docs for each component to get detailed info.
ModelsTableServerPaginated has a lot of options you may configure, but there are two required properties called data
and columns
. First one contains data-query:
model: function() {
return this.store.query('my-model', {});
}
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:
- When using
filterWithSelect
for a column, you must usepredefinedFilterOptions
, because the automatic loading of possible filter values cannot work here. - There is a new optional field
filteredBy
for columns, which works much likesortedBy
: if set, this field will be used as query parameter, otherwise it will use thepropertyName
. - Sorting will not use multipleColumnSorting, it will only sort by one column.
- If you set
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:
// The property on meta to load the pages count from.
metaPagesCountProperty: 'pagesCount',
// The property on meta to load the total item count from.
metaItemsCountProperty: 'itemsCount',
// The time to wait until new data is actually loaded.
// This can be tweaked to avoid making too many server requests.
debounceDataLoadTime: 500,
// The query parameters to use for server side filtering / querying.
filterQueryParameters: {
globalFilter: 'search',
sort: 'sort',
sortDirection: 'sortDirection',
page: 'page',
pageSize: 'pageSize'
},
This default configuration would try to get the total page count from model.get('meta.pagesCount')
and the total item count from model.get('meta.itemsCount')
, and would then go on to build the following query:
columns: [
{
propertyName: 'name',
filteredBy: 'model_name'
}
]
// after searching globally for "searchtexthere"
// and in the name column for "filterforname",
// and going to page 2,
// the following query would be built:
?page=2&pageSize=50&search=searchtexthere&sort=name&sortDirection=ASC&model_name=filterforname
Item Index
Methods
- _clearFilters
- _createColumn
- _createColumnHash
- _loadData
- _multiColumnsSorting
- _postProcessColumn
- _sendColumnsVisibilityChangedAction
- _setupColumns
- _setupColumnsComponent
- _setupColumnsOnce
- _setupPageSizeOptions
- _singleColumnSorting
- actions.clearFilters
- actions.clickOnRow
- actions.collapseAllRows
- actions.collapseRow
- actions.doubleClickOnRow
- actions.expandAllRows
- actions.expandRow
- actions.gotoCustomPage
- actions.hideAllColumns
- actions.hoverOnRow
- actions.outRow
- actions.restoreDefaultVisibility
- actions.sendAction
- actions.showAllColumns
- actions.sort
- actions.toggleAllSelection
- actions.toggleColumnSet
- actions.toggleGroupedRows
- actions.toggleGroupedRowsExpands
- actions.toggleGroupedRowsSelection
- actions.toggleHidden
- checkColumnTitles
- collapseRowOnNavigate
- doQuery
- focus
- forceToFirstPage
- getCustomFilterTitle
- multipleColumnsSortingWrapper
- rebuildTable
- setQueryFilter
- setup
- singleColumnSortingWrapper
- updateColumns
- updateHeaderCellsColspan
- updateHeaderCellsColspanOnce
- userInteractionObserver
- userInteractionObserverOnce
- visibleContentObserver
- visibleContentObserverOnce
Properties
- allColumnsAreHidden
- anyFilterUsed
- arrangedContent
- arrangedContentLength
- checkTextTranslations
- collapsedGroupValues
- columnComponents
- columnDropdownOptions
- columnFieldsToCheckUpdate
- columns
- columnsAreUpdateable
- columnSets
- currentGroupingPropertyName
- currentPageNumber
- data
- dataGroupOptions
- dataGroupProperties
- debounceDataLoadTime
- displayGroupedValueAs
- doFilteringByHiddenColumns
- expandedItems
- expandedRowComponent
- filteredContent
- filteringIgnoreCase
- filterQueryParameters
- filterString
- firstIndex
- focusGlobalFilter
- globalFilterUsed
- groupedArrangedContent
- groupedHeaders
- groupedVisibleContent
- groupedVisibleContentValuesOrder
- groupHeaderCellComponent
- groupingRowComponent
- groupSummaryRowComponent
- isError
- isLastPage
- isLoading
- lastIndex
- metaItemsCountProperty
- metaPagesCountProperty
- multipleColumnsSorting
- multipleExpand
- multipleSelect
- noHeaderFilteringAndSorting
- observedProperties
- pagesCount
- pageSize
- pageSizeOptions
- pageSizeValues
- processedColumns
- publicAPI
- registerAPI
- selectedItems
- selectRowOnClick
- showColumnsDropdown
- showComponentFooter
- showGlobalFilter
- showPageSize
- sortByGroupedFieldDirection
- sortFunctions
- sortMap
- sortProperties
- themeInstance
- useDataGrouping
- useFilteringByColumns
- useNumericPagination
- visibleContent
- visibleProcessedColumns
- {number} rowspan HTML rowspan attr
Methods
_clearFilters
()
Undefined
private
Returns:
_createColumn
-
options
`
js
_createColumn(options) {
const hash = this._createColumnHash(options);
const column = ModelsTableColumn.extend(hash).create(options);
return this._postProcessColumn(column);
}
`
Parameters:
-
options
Object
Returns:
_createColumnHash
-
options
extend
Parameters:
-
options
Object
Returns:
_loadData
()
Promise
private
This function actually loads the data from the server. It takes the store, modelName and query from the passed in data-object and adds page, sorting & filtering to it.
Returns:
_multiColumnsSorting
-
column
-
sortedBy
-
newSorting
sortProperties
when multi-columns sorting is used
Returns:
_postProcessColumn
-
column
Parameters:
-
column
Object
Returns:
_sendColumnsVisibilityChangedAction
()
Undefined
private
columnsVisibilityChangedAction
-action when user changes which columns are visible.
Action is sent if columnsVisibilityChangedAction
is a closure action
Returns:
_setupColumns
()
Undefined
private
columns
Returns:
_setupColumnsComponent
-
c
-
column
columns
for components
Parameters:
-
c
ModelsTableColumn -
column
Objectraw column
Returns:
_setupColumnsOnce
()
Undefined
private
_setupColumns
to call it only once when observer is fired
Returns:
_setupPageSizeOptions
()
Undefined
private
pageSizeValues
equal to an array with numbers and not objects
pageSizeValues
is live as is, pageSizeOptions
is used in the templates
Returns:
_singleColumnSorting
-
column
-
sortedBy
-
newSorting
sortProperties
when single-column sorting is used
Returns:
actions.clearFilters
()
Undefined
Returns:
actions.clickOnRow
-
index
-
dataItem
selected
-state for row. Select only one or multiple rows depends on {{#crossLink 'Components.ModelsTable/multipleSelect:property'}}multipleSelect{{/crossLink}} value. May trigger sending {{#crossLink 'Components.ModelsTable/displayDataChangedAction:property'}}displayDataChangedAction{{/crossLink}}
Returns:
actions.collapseAllRows
()
Undefined
Returns:
actions.collapseRow
-
index
-
dataItem
Returns:
actions.doubleClickOnRow
-
index
-
dataItem
Returns:
actions.expandAllRows
()
Undefined
true
. May trigger sending {{#crossLink 'Components.ModelsTable/displayDataChangedAction:property'}}displayDataChangedAction{{/crossLink}}
Returns:
actions.expandRow
-
index
-
dataItem
false
. Expanding is assigned to the record itself and not their index. So, if page #1 has first row expanded and user is moved to any another page, first row on new page won't be expanded. But when user will be back to the first page, first row will be expanded. May trigger sending {{#crossLink 'Components.ModelsTable/displayDataChangedAction:property'}}displayDataChangedAction{{/crossLink}}
Returns:
actions.gotoCustomPage
-
pageNumber
Parameters:
-
pageNumber
Number
Returns:
actions.hideAllColumns
()
Undefined
Returns:
actions.hoverOnRow
-
index
-
dataItem
Returns:
actions.outRow
-
index
-
dataItem
Returns:
actions.restoreDefaultVisibility
()
Undefined
Returns:
actions.sendAction
()
Undefined
sendAction
signature is the same as Ember.Component#sendAction
Returns:
actions.showAllColumns
()
Undefined
isHidden
value to false
. May trigger sending {{#crossLink 'Components.ModelsTable/columnsVisibilityChangedAction:property'}}columnsVisibilityChangedAction{{/crossLink}}
Returns:
actions.sort
-
column
Parameters:
-
column
ModelsTableColumn
Returns:
actions.toggleAllSelection
()
Undefined
Returns:
actions.toggleColumnSet
()
Undefined
Returns:
selectedItems
is provided
multipleSelected
may be set true
if selectedItems
has more than 1 item
Returns:
actions.toggleGroupedRows
-
groupedValue
Parameters:
-
groupedValue
Returns:
actions.toggleGroupedRowsExpands
-
groupedValue
multipleExpand
should be set to true
otherwise this action won't do anything
Parameters:
-
groupedValue
Returns:
actions.toggleGroupedRowsSelection
-
groupedValue
multipleSelect
should be set to true
otherwise this action won't do anything
May trigger sending {{#crossLink 'Components.ModelsTable/displayDataChangedAction:property'}}displayDataChangedAction{{/crossLink}}
Parameters:
-
groupedValue
Returns:
actions.toggleHidden
-
column
Parameters:
-
column
ModelsTableColumn
Returns:
checkColumnTitles
()
Undefined
private
Returns:
doQuery
-
store
-
modelName
-
query
Do query-request to load new data
You may override this method to add some extra behavior or even additional requests
Returns:
focus
()
Undefined
Returns:
forceToFirstPage
()
Undefined
private
Returns:
getCustomFilterTitle
-
column
Customize filter title
Parameters:
-
column
Object
Returns:
title
multipleColumnsSortingWrapper
-
query
-
sortProperties
Wrapper for sorting query when multi columns sorting is used
Returns:
query parameters
rebuildTable
()
Undefined
Returns:
setQueryFilter
-
query
-
column
-
filterTitle
-
filter
Actually set the filter on a query. This can be overwritten for special case handling. Note that this will mutate the given query object!
Parameters:
Returns:
setup
()
Undefined
Returns:
singleColumnSortingWrapper
-
query
-
sortBy
-
sortDirection
Wrapper for sorting query when single column sorting is used
Returns:
query parameters
updateColumns
()
Undefined
Returns:
updateHeaderCellsColspan
()
Undefined
private
Returns:
updateHeaderCellsColspanOnce
()
Undefined
private
Returns:
userInteractionObserver
()
Undefined
private
displayDataChangedAction
-action when user does sort of filter.
Action is sent if displayDataChangedAction
is a closure-action
Returns:
userInteractionObserverOnce
()
Undefined
private
Returns:
visibleContentObserver
()
Undefined
private
Returns:
visibleContentObserverOnce
()
Undefined
private
Returns:
Properties
arrangedContent
Object[]
private
For server side filtering, arrangedContent is same as the filtered content
arrangedContentLength
Number
private
The total content length is get from the meta information. Set metaItemsCountProperty to change from which meta property this is loaded.
checkTextTranslations
Boolean
Default: false
collapsedGroupValues
Array
Default: []
columnComponents
Object
Default: {}
columnDropdownOptions
showAll: boolean, hideAll: boolean, restoreDefaults: boolean, columnSets: object
private
columnFieldsToCheckUpdate
String[]
columns
fields which are observed to update shown table-columns
It is used only if columnsAreUpdateable
is true
Default: ['propertyName', 'component']
columns
Object[]
Default: []
columnsAreUpdateable
Boolean
processedColumns
will be updated if columns
are changed (propertyName
and
template
are observed)
IMPORTANT All filter, sort and visibility options will be dropped to the default values while updating
Default: false
columnSets
Object[]
label
(string) - The label for the set. This will be displayed in the columns dropdown.
* showColumns
(array|Function) - This should either be an array of propertyNames
to show, or a function. If it is a function, the function will be called with the processedColumns
as attribute.
* hideOtherColumns
(boolean) - If this is true (default), all columns not specified in showColumns
will be hidden. If this is set to false, other columns will be left at whatever visibility they were before.
* toggleSet
(boolean) - If this is true (default is false), the set columns will be shown if one of them is currently hidden,
else they will all be hidden. Settings this will result in a default of hideOtherColumns=false
Default: []
currentGroupingPropertyName
String
true
Default: null
data
Object[]
Default: []
dataGroupProperties
String[] | Object[]
label
and value
properties for each list item
**IMPORTANT** It must contain {{#crossLink 'Components.ModelsTable/currentGroupingPropertyName:property'}}currentGroupingPropertyName{{/crossLink}}-value
Default: []
debounceDataLoadTime
Number
The time to wait until new data is actually loaded. This can be tweaked to avoid making too many server requests.
Default: 500
displayGroupedValueAs
String
row
and column
Default: 'row'
doFilteringByHiddenColumns
Unknown
Can't be used within models-table-server-paginated
. Back-end determines how to filter data
expandedItems
Object[]
Default: null
expandedRowComponent
Object
record
- current row value
* processedColumns
- current column (one of the {{#crossLink 'Components.ModelsTable/processedColumns:property'}}processedColumns{{/crossLink}})
* index
- current row index
* selectedItems
- bound from {{#crossLink 'Components.ModelsTable/selectedItems:property'}}selectedItems{{/crossLink}}
* visibleProcessedColumns
- bound from {{#crossLink 'Components.ModelsTable/visibleProcessedColumns:property'}}visibleProcessedColumns{{/crossLink}}
* clickOnRow
- closure action {{#crossLink 'Components.ModelsTable/actions.clickOnRow:method'}}ModelsTable.actions.clickOnRow{{/crossLink}}
* sendAction
- closure action {{#crossLink 'Components.ModelsTable/actions.sendAction:method'}}ModelsTable.actions.sendAction{{/crossLink}}
* themeInstance
- bound from {{#crossLink 'Components.ModelsTable/themeInstance:property'}}themeInstance{{/crossLink}}
Usage:
`
hbs
{{models-table data=model columns=columns expandedRowComponent=(component "expanded-row")}}
`
Default: null
filteredContent
Object[]
private
This is set during didReceiveAttr and whenever the page/filters change.
Default: []
filteringIgnoreCase
Unknown
Can't be used within models-table-server-paginated
. Back-end determines how to filter data
focusGlobalFilter
Boolean
Default: false
groupedArrangedContent
Object[]
private
groupedHeaders
GroupedHeader[]
title
(string) - Header for grouped column
* colspan
(number) - HTML colspan attr
* rowspan
(number) - HTML rowspan attr
Default: []
groupedVisibleContent
Object
private
Default: {}
groupedVisibleContentValuesOrder
Array
private
groupHeaderCellComponent
Object
true
and
{{#crossLink 'Component.ModelsTable/displayGroupedValueAs:property'}}displayGroupedValueAs{{/crossLink}} is not columns
Usage:
`
hbs
{{models-table data=model columns=columns groupHeaderCellComponent=(component "group-header-cell")}}
`
Component will receive such options:
* currentGroupingPropertyName
- property name used to group rows in the current moment
Default: null
groupingRowComponent
Object
true
Component will receive several options:
* groupedValue
- grouped property value
* currentGroupingPropertyName
- bound from {{#crossLink 'Components.ModelsTable/currentGroupingPropertyName:property'}}currentGroupingPropertyName{{/crossLink}}
* displayGroupedValueAs
- bound from {{#crossLink 'Components.ModelsTable/displayGroupedValueAs:property'}}ModelsTable.displayGroupedValueAs{{/crossLink}}
* toggleGroupedRows
- closure action {{#crossLink 'Components.ModelsTable/actions.toggleGroupedRows:method'}}ModelsTable.actions.toggleGroupedRows{{/crossLink}}
* toggleGroupedRowsExpands
- closure action {{#crossLink 'Components.ModelsTable/actions.toggleGroupedRowsExpands:method'}}ModelsTable.actions.toggleGroupedRowsExpands{{/crossLink}}
* toggleGroupedRowsSelection
- closure action {{#crossLink 'Components.ModelsTable/actions.toggleGroupedRowsSelection:method'}}ModelsTable.actions.toggleGroupedRowsSelection{{/crossLink}}
* visibleProcessedColumns
- bound from {{#crossLink 'Components.ModelsTable/visibleProcessedColumns:property'}}ModelsTable.visibleProcessedColumns{{/crossLink}}
* themeInstance
- bound from {{#crossLink 'Components.ModelsTable/themeInstance:property'}}ModelsTable.themeInstance{{/crossLink}}
* sendAction
- closure action {{#crossLink 'Components.ModelsTable/actions.sendAction:method'}}ModelsTable.actions.sendAction{{/crossLink}}
* groupedItems
- list of all rows group items
* visibleGroupedItems
- list of rows group items shown on the current table page
* selectedGroupedItems
- list of selected rows group items
* expandedGroupedItems
- list of expanded rows group items
Usage:
`
hbs
{{models-table data=model columns=columns groupingRowComponent=(component "grouping-row")}}
`
Default: null
groupSummaryRowComponent
Object
true
Component will receive several options:
* visibleProcessedColumns
- bound from {{#crossLink 'Components.ModelsTable/visibleProcessedColumns:property'}}ModelsTable.visibleProcessedColumns{{/crossLink}}
* themeInstance
- bound from {{#crossLink 'Components.ModelsTable/themeInstance:property'}}ModelsTable.themeInstance{{/crossLink}}
* sendAction
- closure action {{#crossLink 'Components.ModelsTable/actions.sendAction:method'}}ModelsTable.actions.sendAction{{/crossLink}}
* groupedItems
- list of all rows group items
* visibleGroupedItems
- list of rows group items shown on the current table page
* selectedGroupedItems
- list of selected rows group items
* expandedGroupedItems
- list of expanded rows group items
Usage:
`
hbs
{{models-table data=model columns=columns groupSummaryRowComponent=(component "group-summary-row")}}
`
Default: null
isError
Boolean
private
True if last data query promise has been rejected. Can be used in the template to e.g. indicate stale data or to e.g. show error state.
Default: false
isLoading
Boolean
private
True if data is currently being loaded from the server. Can be used in the template to e.g. display a loading spinner.
Default: false
metaItemsCountProperty
String
The property on meta to load the total item count from.
Default: 'itemsCount'
metaPagesCountProperty
String
The property on meta to load the pages count from.
Default: 'pagesCount'
multipleExpand
Boolean
Default: false
multipleSelect
Boolean
false
- only one row may be selected in the same time
Default: false
noHeaderFilteringAndSorting
Boolean
private
true
if all processedColumns don't use filtering and sorting
pagesCount
Number
private
The pages count is get from the meta information. Set metaPagesCountProperty to change from which meta property this is loaded.
pageSizeOptions
Value: string | Number, label: string | Number
private
pageSizeValues
This value should not be set manually!
Default: []
pageSizeValues
Number[]
pageSize
values. Used to change size of visibleContent
Default: [10, 25, 50]
processedColumns
Object[]
private
Default: []
publicAPI
Object
registerAPI
ClosureFunction
Default: null
selectedItems
Object[]
true
Default: null
selectRowOnClick
Boolean
false
- no row can be selected
Default: true
sortByGroupedFieldDirection
String
private
Default: 'asc'
sortMap
Object
Default: {{ none: 'asc', asc: 'desc', desc: 'none' }}
sortProperties
String[]
private
Default: []
themeInstance
Themes.Bootstrap3
themeInstance
is an instance of [DefaultTheme](Themes.Default.html) or it's children.
By default models-table
uses [BootstrapTheme](Themes.Bootstrap.html) instance.
You may create your own theme-class and set themeInstance
to it's instance. Check Theme properties you may define in your own theme.
useDataGrouping
Boolean
Default: false
useFilteringByColumns
Boolean
Default: true
visibleContent
Object[]
private
For server side filtering, visibleContent is same as the filtered content
Events
columnsVisibilityChangedAction
{ propertyName: 'firstName', isHidden: true, mayBeHidden: false }
* Usage:
`
hbs
{{models-table data=model columns=columns columnsVisibilityChangedAction=(action "someAction")}}
`
displayDataChangedAction
sort
- list with sort value propertyName:sortDirection
* currentPageNumber
- currently shown page number
* pageSize
- current page size
* filterString
- global filter value
* filteredContent
- filtered data
* selectedItems
- list with selected row items
* expandedItems
- list with expanded row items
* columnFilters
- hash with fields equal to filtered propertyName and values equal to filter values
Usage:
`
hbs
{{models-table data=model columns=columns displayDataChangedAction=(action "someAction")}}
`
rowDoubleClickAction
`
hbs
{{models-table data=model columns=columns rowDoubleClickAction=(action "someAction")}}
`
rowHoverAction
`
hbs
{{models-table data=model columns=columns rowHoverAction=(action "someAction")}}
`
rowOutAction
`
hbs
{{models-table data=model columns=columns rowOutAction=(action "someAction")}}
`