3.0.11 • Published 2 months ago

@eqproject/eqp-table v3.0.11

Weekly downloads
179
License
MIT
Repository
-
Last release
2 months ago

Table of contents

Required

  • Angular Material installed and imported

Getting started

Step 1: Install eqp-table:

NPM

npm install --save @eqproject/eqp-table

Step 2: Import the EqpTableModule and install :

import { EqpTableModule } from '@eqproject/eqp-table';

@NgModule({
  declarations: [AppComponent],
  imports: [EqpTableModule],
  bootstrap: [AppComponent]
})
export class AppModule {}

Step 2: Use in your component

Define selector in html

<eqp-table [headerTitle]="'Title'" [columns]="columns" [data]="DATA"></eqp-table>

Define the datasource for the table

  @ViewChild(EqpTableComponent) eqpTable: EqpTableComponent; //To access directly the directive
  columns: Array<ConfigColumn>;

 DATA: any[] = [
    { ID: 0, Name: 'Mario', Surname: 'Rossi', BirthDate: new Date(), Gender: 1, Boolean: true},
    { ID: 1, Name: 'Luigi', Surname: 'Bianchi', BirthDate: new Date(), Gender: 2, Boolean: false}
  ];

 genderEnum = GenderEnum; // For enumerators, need only to create variable and assign to enumerator

Define the column configurations

  this.columns = [
    {
        key: "Name",
        display: "Name"
      },
      {
        key: "Surname",
        display: "Surname",
      },
      {
        key: "BirthDate",
        display: "Birth Date",
        type: TypeColumn.Date,
        styles: { flex: "0 0 8%" }
      },
      {
        key: "Gender",
        display: "Gender",
        type: TypeColumn.Enum,
        enumModel: GenderEnum,
        styles: { flex: "0 0 8%" }
      }
  ];

Step 3: Use Example to reload the table :

On onInit, you can call a reload method, that will only refresh the table using viewchild we previously created

this.eqpTable.reloadDatatable(data);

Multilanguage

Step 4(not required): Use Multilanguage :

To use multilanguage, set to true the input boolean variable

    <eqp-table [isMultiLanguage]="true"></eqp-table>

Then, where you set the language to use, like on login page or in navbar to switch language

    this.translateHelper.loadJsonLanguage("en", jsonObject);

Where translateHelper is a service that need to be imported in constructor component as public.

loadJsonLanguage need to set current language, first parameter check the language to use, in the second we need to pass the entire Json for selected language

API

Inputs for basic table configuration

InputTypeDefaultRequiredDescription
headerTitlestring-noSet the table title.
dataArray<any>-yesArray of generic objects with properties.
columnsArray<ConfigColumn>-yesArray with ConfigColumn as type, need to initialize and import in component
createMatCardbooleanfalsenoIf true, a mat-card will be created as a container for the table
createMatCardHeaderbooleanfalsenoSe true, verrà creato una mat-card-header come contenitore del titolo della tabella
tableNamestring-noIt allows you to define the table name, currently used to save the pagination of the specific table that you want to modify. If omitted, a unique name is automatically assigned to each eqp-table
emptyTableMessagestringNessun dato trovatonoText to show if the table is empty
disableRowstring|Function|boolean-noVisually disable the row. It accepts a string containing the name of a property that must be contained in the table and that MUST return Boolean values, otherwise it accepts a Function with the same behavior or a Booelan value
isMultiLanguagebooleanfalsenoIf true, see section and examples about use, if not interested in use, set to false or don't write it
cultureInfostringit-ITnoDefinition of the cultureInfo to use for the data filter format in the table
showFunctionButtonsbooleanfalsenoIf true, the 'Confirm' and 'Cancel' buttons are shown in the footer. It will be possible to pass functions to be invoked by pressing the buttons
functionButtonConfirmTextstringConfermanoConfirm button text, by default it will return 'Confirm'
functionButtonExitTextstringEscinoExit button text, by default it will return 'Exit'
tableColorstring (RGB o HEX)whitenoAllows you to define the background color of the table
exportEqpTableExportEqpTablenullnoAllows you to configure the export functionality of the data shown in the table (refer to the configuration of the ExportEqpTable model)
currencyFilterToReplacestringnullnoN.D.
currencyFilterToUsestringnullnoN.D.
showFirstLastButtonsbooleanfalsenoAllows you to show first and last page button in paginator
showFirstLastButtonsbooleanfalsenoAllows you to show first and last page button in paginator
disablePageStorageSavebooleanfalsenoAllows you to disable pagination storage save on localstorage
disableRowColorstring (RGB o HEX)#8080808cnoAllows you to define color of the disabled rows
autoResizeColumnsbooleanfalsenoBETA - the table will become adaptive, the columns that do not fit on the screen will go into the expandable table detailing each row.You can use flex, minWidth or maxWidth for each column otherwise a default value will be set for each column
chooseColumnsToShowbooleanfalsenoUser can select the columns he wants to see in the table
chooseColumnsToShowTextstringVisualizza colonnenoText on dialog title for the columns to show
rowCssClassFunction|stringnullnoClasses that will be applied to mat-row, the function MUST return a string
cellCssClassFunction|stringnullnoClasses that will be applied to mat-cell, the function MUST return a string
headerCellCssClassFunction|stringnullnoClasses that will be applied to mat-header, the function MUST return a string
isStickyHeaderbooleanfalsenoHeader will be sticky
customButtonsCustomButtonfalsenoAllows you to configure the custom buttons at the top of table (refer to the configuration of the CustomButton model)

Inputs for table lookup functionality (searching)

InputTypeDefaultRequiredDescription
isTableSearcheablebooleantruenoManages the visibility of the search field above the table, default true. If False then the search field is hidden
searchTextstringCercanoLabel to be applied to the text search field
isSingleColumnFilterbooleanfalsenoIt defines if the search is done by single column or if global
switchFilterTypebooleanfalsenoIt allows you to configure the switch functionality between the global search and the single column search.
singleFilterColumnVisiblebooleantruenoIt allows you to manage the expand / collapse status of the accordion relating to the search fields on a single column
showSingleFilterButtonbooleantruenoIf the use of filters on a single column has been requested, through this input it will be possible to open / close the agreement between the header and the body of the table containing the filters on a single column
switchFilterToGenericTextstringUsa filtro genericonoTooltip text of the switch button in case generic filters are to be shown
switchFilterToSingleTextstringUsa filtro per singola colonnanoToggle button tooltip text in case single column filters are to be shown
showFilterTextstringMostra filtrinoText of the button to open the accordion of the search fields on a single column
hideFilterTextstringNascondi filtrinoText of the button to close the accordion of the search fields on a single column

Inputs for table pagination

InputTypeDefaultRequiredDescription
paginatorVisiblebooleantruenoAllows you to show / hide the pagination under the table, default true. If it is set to FALSE then the table will have no paging
matPaginatorLengthArray<number>[5,10,25,100]noIt allows to define an array of numbers to indicate the possible pagination dimensions of the table, default: 5, 10, 25, 100
matPaginatorSizenumber5noAllows you to define the default number to be used for the elements to be displayed on each page
matPaginatorIndexnumber-noAllows you to define the index of the page size array to use to be set by default.
matPaginatorCountnumber-noN.D.
paginatorColorstring (HEX o RGB)-noAllows you to define the paginator background color (HEX or RGB)

Inputs for table selection

InputTypeDefaultRequiredDescription
selectionbooleanfalsenoIf true, single select functionality is added on the table (default: false)
isMultipleSelectionbooleanfalsenoIf it assumes the value true and if the input 'selection' takes the value true then it adds the functionality of multiple selection of the table rows
isHighlightbooleanfalsenoDefines whether the table highlights the selected row (passing an output event for the row)
highlightColorstring#E4E5E6noDefinition of the highlight color, default is #E4E5E6 (gray), N.B. it must be RGB
isSelectedPropertyNamestringisSelectednoAllows you to define property name for checkbox function

Table Outputs

OutputEvent ArgumentsRequiredDescription
(checkboxInfo)EventEmitter<anynoInvoked only if the selection is active on the eqp-table. It is invoked every time the selection on the rows changes and passes as a parameter the array of the rows that are selected
(pageChange)EventEmitter<any>noInvoked whenever the pagination of the table changes. Exposes an object containing the following properties: previousSize, pageIndex, pageSize
(sortChange)EventEmitter<any>noEvent triggered when the ordering on a column is changed, an object containing the name of the column and the direction of the ordering is passed as a parameter
(highlightSelected)EventEmitter<any>noEvent active only if the selection on the table is active. It is invoked at each selection made and passes the selected line as a parameter
(highlightDeselected)EventEmitter<any>noEvent active only if the selection on the table is active. It is invoked at each deselection made and passes the deselected line as a parameter
(functionButtonConfirm)EventEmitter<any>noEvent active only if the 'showFunctionButtons' input takes on the value TRUE. It is invoked when the 'Confirm' button is pressed and passes as a parameter the array of rows selected on the table (if present)
(functionButtonExit)EventEmitter<any>noEvent active only if the 'showFunctionButtons' input takes on the value TRUE. It is invoked when the 'Exit' button is pressed and passes the value NULL as a parameter
(eqpExportStarted)EventEmitter<any>noEvent triggered when the table export function starts. It is active only if the 'exportEqpTable' input is configured.
(eqpExportCompleted)EventEmitter<any>noEvent triggered at the end of the table export function. It is active only if the 'exportEqpTable' input is configured.

Models used

ConfigColumns Model

PropertyDescriptionExamplesType
keyUnique name to be assigned to the column (may coincide with the name of the property to be displayed)-string
displayDisplayed value-string
valueIf the specified key does not coincide with the name of the property then this node must contain the name of the property to be displayed or, possibly, the function to be called to return the value to be shown in the column.-string|Function
typeTypeColumn - define with enumerator the column typeDate = 1, Boolean = 2, SimpleAction = 3, MenuAction = 4, Enum = 5, Icon = 6, Checkbox = 7, Hyperlink = 8, Image = 9, Color = 10, ExternalTemplate = 11TypeColumn Enum
formatUsed to define Date format by stringdefault value - format: 'dd/MM/yyyy'string
numberPipeAllows you to define the numeric pipe to be used.A value chosen from: DECIMAL = 1; PERCENT = 2; CURRENCY = 3NumberColumnPipe
currencyPipeCodeAllows you to define the pipe to be used for columns containing a currency. It can be a static value (a string) or a function (if for example there are different currencies on the lines)-string|Function
actionsAllows you to define the actions for the SIMPLE_ACTION or MENU_ACTION type column-Array<ConfigAction>
booleanValuesCan define display value for 'true' and 'false' casestrue: 'Si' false: 'No'BooleanValues
enumModelPassed enum type, automatically retrieve the value-any
buttonMenuIconDefine the button icon in menu cases-string
iconsN.D.--
stylesN.D.--
containerStyleN.D.--
isSearchableAllows you to activate / deactivate the search for the current column-boolean
disabledAllows you to enable / disable the column based on a value or the result of a function-boolean|Function
multilanguagePrefixKeyIf the multilingual is active for the table and the current column contains, for example, an enumerator to be translated, in this field it is possible to indicate the possible prefix to search for the translated value in the translation dictionary passed as input.-string
tooltipN.D.--
hyperlinkN.D.--
imageN.D.--
additionalValueIt allows you to define a static text that will always be displayed as a suffix of the text shown in the cell-string
externalTemplateAllows you to define the external template to be used as the content of the column-TemplateRef<any>
externalTemplateSearchFunctionAllows you to define the value for which template will be searched. It can be a static value (a string) or a function-string|Function
isSortableAllows you to activate / deactivate the sorting on the current column-boolean
isFilterableAllows you to activate / deactivate filter on the current column when using eqp-filters-boolean
isHiddenAllows you to hide current column, when using 'chooseColumnsToShow', deselected columns will be automatically set to true-boolean
isStickyAllows you to stick current column to the left of the table (when scrolled after its position) NOTE: Flex is not fully compatible, it is recommended to use MinWidth-boolean
isStickyEndAllows you to stick current column to the right of the table making it always visible-boolean

ConfigAction Model

PropertyDescriptionTypeRequired
nameAction namestringno
iconMat Icon for menu iconstring|Functionno
disabledMat Icon for menu iconboolean|Functionno
fnUsed to define function-any|Function
hiddenUsed to define functionboolean|Functionno
fontawesomeUsed to define functionbooleanno
tooltipUsed to define functionEqpMatTooltipno
colorUsed to define functionstringno

ExportEqpTable Model

PropertyDescriptionTypeRequired
exportFileTypeN.D.ExportType | Array<ExportType> | CustomExportType | Array<CustomExportType>no
exportFileNameN.D.stringno
hiddenColumnsN.D.Array<number>no
buttonTextN.D.stringno
buttonTextTranslateKeyN.D.stringno
buttonIconN.D.stringno
tooltipTextN.D.stringno
tooltipTextTranslateKeyN.D.stringno
tooltipPositionN.D.TooltipPositionTypeno
showButtonBorderN.D.booleanno
customExportFunctionN.D.Array<Function>no

CustomButton Model

PropertyDescriptionTypeRequired
buttonTextN.D.stringno
buttonTextTranslateKeyNeed translate to be defined on the tablestringno
iconN.D.stringno
colorN.D.stringno
orderLeft to rightnumberno
tooltipTextN.D.stringno
tooltipTextTranslateKeyNeed translate to be defined on the tablestringno
tooltipPositionDefault 'below'TooltipPositionTypeno
customButtonFunctionN.D.Functionno

fn Model

PropertyDescription
elementEntire row data
colrow index
elementIndexInformation about the action name and type

Credits

This library has been developed by EqProject SRL, for more info contact: info@eqproject.it

3.0.11

2 months ago

3.0.10

2 months ago

3.0.4

2 months ago

3.0.3

2 months ago

3.0.8

2 months ago

3.0.7

2 months ago

3.0.6

2 months ago

3.0.5

2 months ago

3.0.9

2 months ago

2.5.5

2 months ago

3.0.2

2 months ago

3.0.1

3 months ago

2.5.4

3 months ago

2.5.3

3 months ago

2.5.2

3 months ago

3.0.0

4 months ago

2.5.1

4 months ago

2.5.0

4 months ago

2.0.19

4 months ago

2.0.18

5 months ago

2.0.15

7 months ago

2.0.16

7 months ago

2.0.13

7 months ago

2.0.14

7 months ago

2.0.11

10 months ago

2.0.12

8 months ago

2.0.10

10 months ago

2.0.17

6 months ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.5

11 months ago

2.0.4

1 year ago

2.0.7

11 months ago

2.0.6

11 months ago

2.0.9

11 months ago

2.0.8

11 months ago

0.8.11

1 year ago

0.8.9

2 years ago

0.8.8

2 years ago

0.8.5

2 years ago

0.8.7

2 years ago

0.8.6

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

0.8.10

2 years ago

0.8.4

2 years ago

0.8.3

2 years ago

0.7.9

3 years ago

0.8.1

2 years ago

0.8.0

3 years ago

0.8.2

2 years ago

0.7.8

3 years ago

0.7.6

3 years ago

0.7.7

3 years ago

0.7.5

3 years ago

0.7.4

3 years ago

0.7.3

3 years ago

0.7.2

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.9

3 years ago

0.6.8

3 years ago

0.6.7

3 years ago

0.6.6

3 years ago

0.6.5

3 years ago

0.6.4

3 years ago

0.6.3

3 years ago

0.6.2

3 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.4

3 years ago

0.5.3

3 years ago

0.5.6

3 years ago

0.5.5

3 years ago

0.5.8

3 years ago

0.5.7

3 years ago

0.5.9

3 years ago

0.5.2

3 years ago

0.5.1

3 years ago

0.5.0

3 years ago

0.4.9

3 years ago

0.4.8

3 years ago

0.4.7

3 years ago

0.4.6

3 years ago

0.4.5

3 years ago

0.4.4

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago

0.3.9

3 years ago

0.4.0

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.6

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.3.1

4 years ago

0.2.9

4 years ago

0.2.8

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.5

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago