README
Usage
Add module:
angular.module('app', [
'ttmd.enhancedtable'
]);
Include file:
require('@tt-md-enhancedtable/dist/tt-md-enhancedtable.min.css');
require('@tt-md-enhancedtable/dist/tt-md-enhancedtable.min.js');
Required dependencies
- Angular 1.5.2
- Angular Material 1.0.2
About Adding your translation
Inside library, use {{ value | translate }}
to get the translations.
If you do NOT need translation, you can just pass the string you want to display. If you do need translation, you can pass in the json path as when you use angular translation libaray.
For Example:
{
"title": {
"greeting": "Hello!"
}
}
<ttmd-table toolbar="{title: 'title.greeting'}"></ttmd-table>
Add missing translations:
In mobile view, there are two buttons needs your provide translations for other languages:
{
"util": {
"previous": "",
"next": "",
"noData": ""
}
}
Default value for those are:
{
"util": {
"previous": "Previous",
"next": "Next",
"noData": "There is not Data"
}
}
Features
Desktop view and mobile view
The default breakpoint is 'xs', able to pass breakpoint
bindings to the component
<ttmd-enhanced-table items="vm.items" headers="vm.headers" breakpoint="sm"></ttmd-enhanced-table>
Force Mobile View
If there is a case you only want to display mobile view, pass in force-mobile
:
<ttmd-enhanced-table items="vm.items" headers="vm.headers" force-mobile="true"></ttmd-enhanced-table>
Type
If you need to display multi-tables in a page and there is one large object holds all the data, you might consider use type
It can help to change the talbe data inside that large object.
<ttmd-enhanced-table items="vm.accounts.dueDate" headers="vm.headers" type="dueSoon"></ttmd-enhanced-table>
The type
you pass in , will be the listType
inside js:
this.SomeService.fetchDataAccordingPagination(limit, offset)
.then((res) => {
if(listType){
this.accounts[listType] = [
...res
];
}
})
Toolbar
To display the toolbar for the table, passing tooblar
attr. Which is an object contains title
and icon
:
Here icon
is Material font icon.
sub
will show on the right side to display information
<ttmd-enhanced-table items="vm.items" headers="vm.headers" toolbar="{
title="Due Date"
icon="account_circle"
sub="amountPaid"
}"></ttmd-enhanced-table>
Pagination
To enable pagination, need to pass in total-number
to tell how many items in total. You can passing the callback function to on-page-change
, it will push your a payload
object with limit, offset, listType
.
<ttmd-enhanced-table items="vm.items" headers="vm.headers" total-number="vm.totalNumber" on-page-change="vm.fetchData(payload)"></ttmd-enhanced-table>
Sort and filter
Able to sort
and 'fitler' data according to the attr.
<ttmd-enhanced-table items="vm.items" headers="vm.headers" dataitemkeys="vm.dataitemkeys" filtericon="filtericon"></ttmd-enhanced-table>
Exclude
If there is any attr inside the data you don't want to display on the interface, you can use exclude
:
<ttmd-enhanced-table items="vm.items" headers="vm.headers" exclude="['id']"></ttmd-enhanced-table>
Pipes
You can use Angular built-in filter such as date
& currency
by adding pipies
to format the field:
<ttmd-enhanced-table items="vm.items" headers="vm.headers" pipes="vm.pipes"></ttmd-enhanced-table>
this.pipes = {
currency: {
targets: ['amount', 'amountWithOutTax'],
foramt: '