app.component.html <ej-grid [allowPaging]="true" [allowSorting]="true" [dataSource]="gridData"> <e-columns> <e-column field="OrderID" headerText="Order ID" width="75" textAlign="right"></e-column> <e-column field="CustomerID" headerText="Customer ID" width="80"></e-column> <e-column field="EmployeeID" headerText="Employee ID" width="75" textAlign="right"></e-column> <e-column field="Freight" headerText="Freight" width="75" format="{0:C}" textAlign="right"> </e-column> <e-column headerText="Case Reference" width="110" [template]="true"> <template e-template let-data> <div class="test3"> </div> </template> </e-column> <e-column headerText="Template" width="110" [template]="true"> <template e-template let-data> <div class="test3"><input ej-button [text]="data.Country" (click)="onClick($event)" /></div> </template> </e-column> </e-columns> </ej-grid> app.component.ts import {Component, ViewEncapsulation} from '@angular/core'; @Component({ selector: 'ej-app', templateUrl: 'app/app.component.html', //give the path file for Grid control html file. }) export class AppComponent { public gridData; constructor() { //The datasource "window.gridData" is referred from 'https://js.syncfusion.com/demos/web/scripts/jsondata.min.js' this.gridData = window.gridData; } } |
[index.html]
<script type="text/x-jsrender" id="template">
<img style="width: 75px; height: 70px" src="app/content/images/grid/Employees/{{:EmployeeID}}.png" alt="{{:EmployeeID}}" />
</script>
[app.component.html]
<ej-grid [(dataSource)]="gridData" [columns]=col>
</ej-grid>
[app.component.ts]
constructor(private service: NorthwindService) {
this.col = [{field:"OrderID",isPrimaryKey:true},
{field: "EmployeeID"},
{headerText:"Employee Image", template:"#template"}]
} |
import { NgModule, enableProdMode, ErrorHandler } from '@angular/core';
. . . . .
import {EJAngular2Module,EJTemplateDirective} from 'ej-angular2';
.. . . . . . . .
import { rootRouterConfig } from './app.routes';
. . . .
@NgModule({
imports: [BrowserModule, FormsModule, HttpModule,
EJAngular2Module.forRoot(),
. . . .],
declarations: [AppComponent, HomeComponent, GridComponent,
EJTemplateDirective
],
bootstrap: [AppComponent]
})
export class AppModule { }
|
npm install ej-angular2@15.2.43 --save |