We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to enable inline editing in Angular 4 Data Grid/Table

Platform: JavaScript - EJ 2 |
Control: Grid

The Essential JS 2 Angular 4 Data Grid supports the following edit modes to perform CRUD ( Create, Read, Update and Delete) actions through an interactive UI with simple configuration.

  • Inline
  • Dialog
  • Batch
  • Inline/Dialog Template

In this knowledge base, we are going to explain about, how to enable inline editing in Syncfusion Angular 4 Data Grid.

  1. Grid Editing feature requires EditService and ToolbarService for performing edit actions so we need to define this services in app.module.ts file.

 

import { EditService,ToolbarService } from '@syncfusion/ej2-angular-grids';
 
@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    GridModule
  ],
  providers: [EditService, ToolbarService],
  bootstrap: [AppComponent]
})
export class AppModule { }

 

  1. To perform editing in Angular 4 data grid its requires to set a isPrimaryKey property of column as true for the unique column in the data source since the CRUD actions performed based on this unique column.

 

<ejs-grid [dataSource]='data' [editSettings]='editSettings' [toolbar]='toolbar' height='315px'>
  <e-columns>
    <e-column field='OrderID' headerText='Order ID' textAlign='Right' isPrimaryKey='true' width=100></e-column>
    <e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
    <e-column field='Freight' headerText='Freight' textAlign='Right' width=120 format='C2'></e-column>
    <e-column field='ShipCountry' headerText='Ship Country' width=150></e-column>
  </e-columns>
</ejs-grid>
 

 

  1. To perform CRUD actions using Inline edit mode, it requires to set mode property of editSettings as “Normal” and also need to set allowAdding, allowEditing and allowDeleting property of editSettings as “true” . Define the toolbar items in the toolbar property of data grid.

 

<ejs-grid [dataSource]='data' [editSettings]='editSettings' [toolbar]='toolbar' height='315px'>
  <e-columns>
    <e-column field='OrderID' headerText='Order ID' textAlign='Right' isPrimaryKey='true' width=100></e-column>
    <e-column field='CustomerID' headerText='Customer ID' width=120></e-column>
    <e-column field='Freight' headerText='Freight' textAlign='Right' width=120 format='C2'></e-column>
    <e-column field='ShipCountry' headerText='Ship Country' width=150></e-column>
  </e-columns>
</ejs-grid>
import { Component, OnInit } from '@angular/core';
import { EditSettingsModel, ToolbarItems } from '@syncfusion/ej2-angular-grids';
 
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  public data: Object[];
  public editSettings: EditSettingsModel;
  public toolbar: ToolbarItems[];
  ngOnInit() {
    this.editSettings = { allowEditing: true, allowAdding: true, allowDeleting: true, mode:"Normal" };
    this.toolbar = ['Add', 'Edit', 'Delete', 'Update', 'Cancel'];
     }
}
 

 

Inline edit mode

Summary

In this GitHub repository, the application prepared from the above steps has been committed, and it is readily runnable. If you have any queries or require clarifications. Please let us know in comments below. You can also contact us through our Support forum or Direct-Trac. We are happy to assist you!

ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile