0.8.9 • Published 4 months ago

ngx-agile-table v0.8.9

Weekly downloads
-
License
-
Repository
github
Last release
4 months ago

Angular Agile Table

Ngx-agile-table is a library that has been designed to allow you to quickly display data as table in a simple and efficient way. By simple configuration, this library will produce a responsive table that supports filters by column, ordering by column, pagination and many others. Supported data: Text, Html.

Demo

See live demo Stackblitz.

Versions

Angularngx-agile-tableTranslate Module
>=8.0.0v0.8.1 & v0.8.2NO
>=8.0.0v0.8.4 to v0.8.xYES
>=13.0.0v1.xNO

Installation

The library is available as npm package, so all you need to do is to run the following command

  npm install --save @ngx-translate/core@12.0.0 @ngx-translate/http-loader@4.0.0 ngx-agile-table@v0.8.3

Minimal Setup Example

Import the ngx-agile-table directives into your component.

 import {NgxAgileTableModule} from "ngx-agile-table";
 import {TranslateModule} from '@ngx-translate/core';

Add module NgxAgileTableModule and TranslateModule into your module.ts

// ...

@NgModule({
  imports: [
    // ...
    
    NgxAgileTableModule,
    TranslateModule.forRoot(),
    
    // ...
  ],
  declarations: [ ... ]
})
// ...

Describe table column (name and data property) into your dedicated component

// ...
import {ColumnTable} from "ngx-agile-table";

// ...

columns: ColumnTable[] = [
    new ColumnTable('First Name', 'firstName'),
    new ColumnTable('Last Name', 'lastName'),
    new ColumnTable('Age', 'age'),
    new ColumnTable('Country', 'address.country'),
    new ColumnTable('First P.O Box', 'address.box[0].name')
  ];

// ...

Note : You can use the dot(.) or square brackets([]) to navigate from one property to another.

Next, fetch your data list from the server or build an example like below

customers: any[] = [{
    firstName: 'Romeo',
    lastName: '<strong>Klaus</strong>',
    age: 18,
    address: {
        country: 'Cameroon',
        city: 'Douala',
        box: [
            {
                name: 'Avenue Kenedy',
                code: 3425
            },
            {
                name: 'Rond point Deido',
                code: 8001
            }
        ]
    }
}, 
{
    firstName: 'Eric',
    lastName: '<strong>Laghom</strong>',
    age: 56
}];

Note : Library supported text, number, html as data value. When property does not exist, library put automatically an empty string.

Finally, use ngx-table tag to display your data in html file or in template property

<ngx-table [columnSettings]="columns" [data]="customers"></ngx-table>

Save all files or start angular server using command below

ng serve --open

Well done !!!

Inputs and Outputs descriptions

Inputs

NameTypeDefaultDescription
dataany[] The data array
emptyTextstringNo contentText to display when data array to display empty
columnSettingsColumnTable[] Table columns description
enableColumnFilteringbooleantrueEnable/disable column filtering
enableColumnSortingbooleantrueEnable/disable column sorting
actionButtonsActionButtonTable[] Action button(s) details to be displayed at the beginning of each line
actionButtonTitlestringTitle of the action button column.
collapseActionButtonActionButtonTable'...' buttonDisplay button to tell the user that there are other action buttons
maxActionButtonPerRownumber3Max action button(s) to be displayed at the beginning of each line
collapseActionButtonPositionstringrightAllows you to orient the drop-down list of hidden action buttons to the right or to the bottom.
localPaginationbooleanfalseEnable/disable library support for paging
totalElementsnumber0Total data elements
totalElementsTextstringTotal ElementsTotal element text to diplay
totalPagesnumber0Total pages. Calculate automatically if local pagination enabled.
currentPagenumber1Default active/current page
elementPerPagenumber10Default element per page
elementPerPageListnumber[]20, 50, 100, 200Element per page range
displayGlobalSearchInputbooleanfalseshow/hide global search input
searchTextstringSearchThe search text placeholder
paginationPreviousTextstring<<The text to display on "previous page" button if icon not define
paginationNextTextstring<<The text to display on "next page" button if icon not define
paginationPreviousIconstringThe icon (class or image) to display on "previous page" button
paginationNextIconstringThe icon (class or image) to display on "next page" button
colorVariationLineBreaknumber2Change the font of a line every 2 (by default) occurrences. If the value is 0, the background of any line will not change
heightstringTable max height.Don't forget the unit: px, rem, etc.

Outputs

Name$event TypeDescription
onClickActionButtonActionButtonTableFire on user clicks action button
onPageChangednumberFire on user clicks on a given page. The index of a page starts at 1.
onElementPerPageChangednumberFire on user changes element per page in select tag
onGlobalSearchRequeststringFire on user press enter after type text in global search input

ColumnTable Object

PropertyTypeDescription
titlestringThe title of the column in the table
namePropertystringThe name of the property in an element of the data array (data input). Supported value: Text, Html
displaybooleanToggle the display of columns according to your needs (example: display of a column according to the role of a user)
widthstringThe width of the column. Don't forget the unit: px, rem, etc.
MethodParameter typeDescription
customCell(cellData: any, data?: any) => CellData or stringDefine a custom cell to display. You can return html according your need.

CellData Object

PropertyTypeDescription
valuestringThe data that will be displayed.
researchDatastringThe data to use to arrange or filter the column.
originalanyThe original or raw data.
MethodParameter typeDescription
valueOf(obj: any) => CellDataTransform an Object to CellData Object.

ActionButtonTable Object

PropertyTypeDescription
keystringThe unique key to distinct each action button
htmlstringThe button html to display
iconstringThe button image or a style class (fa fa-users) if no html define
textstringThe button text to display if no icon define
tooltipstringText to display when mouse over button. Defaults to the value of the text property.
targetDataanyThe element where the action button is located
targetnumberIndex of the selected element according to the array of input data.
cssValuestringCustom classes to the button. Classes are added to the button. To add multiple classes, the value should be space separated class names.
MethodParameter typeDescription
displayCondition(data: any) => booleanDefine a condition to display the button according to an element of the input data array. By default, action buttons are always displayed.

Features

  • Responsive table
  • Reactive table
  • Filtering
  • Sorting
  • Pagination
  • Translation
  • Easy customization

License

The MIT License (MIT)

Copyright (c) 2022

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Authors

0.8.9

4 months ago

0.8.8

4 months ago

0.8.5

8 months ago

0.8.4

8 months ago

0.8.7

7 months ago

0.8.6

8 months ago

1.0.8

8 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

0.8.3

8 months ago

0.8.2

8 months ago

0.8.1

1 year ago

0.8.0

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago