Press "Enter" to skip to content

Angular Material Table with Edit and Delete Button | ng-editable-table

ng-editable-table is a dynamic angular table, you can add, edit or delete rows without any style sheet.

inline editable table angular 8, angularmaterial editable table, angularmaterial table with edit and delete button, angularmaterial table editable row

How to make use of it:

Installation:

npm install ng-editable-table --save

1. You will need to add the EditableTableModule to your application module.

import { EditableTableModule } from 'ng-editable-table/editable-table/editable-table.module';
    @NgModule({
      imports: [
        EditableTableModule
      ],
      declarations: [
        AppComponent
      ],
      providers: [],
      bootstrap: [AppComponent]
      export class AppModule {}
})

2. You need to create an array of headers and rows to use the ng-editable-table directive.

@Component({
  selector: 'app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  tableHeaders = ['Header 1', 'Header 2', 'Header 3'];
  tableRows = [
    ['Cell', 'Cell', 'Cell'],
    ['Cell', 'Cell', 'Cell'],
    ['Cell', 'Cell', 'Cell']
  ];
    constructor() {}
  ...
}

3. Finally, add this directive to your html:

<nv-editable-table [table-headers]="tableHeaders" [table-rows]="tableRows" ></nv-editable-table>

Directive Options

You can customize the table options by the nv-editable-table the directive, the available options are:

OptionValueDescription
table-headersString ArrayAn array of strings with headers name
table-rowsArray of any []An array of any[] with the content of the row
table-rows-with-idArray of any []An array of any[] with the content of the row, using the first value like row ID, useful to identify objects and rows
can-delete-rowstrue/falseEnable or disable the delete rows button
can-edit-rowstrue/falseEnable or disable the edit rows button
can-add-rowstrue/falseEnable or disable add rows button
add-button-labelStringString label for add button
edit-button-labelStringString label for the edit button
save-button-labelStringString label for save button
cancel-button-labelStringString label for cancel button
delete-button-labelStringString label for the delete button
add-iconStringIcon class for add button
edit-iconStringIcon class for the edit button
save-iconStringIcon class for save button
delete-iconStringIcon class for the delete button
add-button-classStringAdd button class
edit-button-classStringEdit/save button class
delete-button-classStringDelete button class
tr-classStringTable row class
td-classStringTable cell class
buttons-td-classStringButtons column class

You can catch the edit and delete events using the directive outputs:

OptionDescription
onSaveReturn an event when the button save is clicked
onRemoveReturns an event when the button remove is clicked

angular editable table component, ng-editable-table Plugin/Github, angular editable table row, angular material inline editable table


See Demo And Download

Official Website(BennyFranco): Click Here

This superior jQuery/javascript plugin is developed by BennyFranco. For extra advanced usage, please go to the official website.

Be First to Comment

    Leave a Reply

    Your email address will not be published.