Index.ts
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
import { Grid, Selection } from '@syncfusion/ej2-grids';
import { Query, DataManager,DataUtil } from '@syncfusion/ej2-data';
import { orderData } from './data-source';
Grid.Inject(Selection);
/**
* Default Grid sample
*/
DataUtil.serverTimezoneOffset = new Date().getTimezoneOffset()/60;
let data: Object = new DataManager(orderData as JSON[]).executeLocal(new Query().take(15));
let grid: Grid = new Grid(
{
dataSource: data,
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 120, textAlign: 'Right' },
{ field: 'CustomerName', headerText: 'Customer Name', width: 150 },
{ field: 'OrderDate', headerText: 'Order Date', width: 130, format: { type: 'dateTime', format: 'dd/MM/yyyy HH:mm:ss' }, textAlign: 'Right' },
{ field: 'Freight', width: 120, format: 'C2', textAlign: 'Right' }
]
});
grid.appendTo('#Grid');
|
Index.ts
DataUtil.serverTimezoneOffset = new Date().getTimezoneOffset()/60;
let hostUrl: string = 'https://ej2services.syncfusion.com/production/web-services/';
let data: Object = new DataManager({
url: hostUrl + 'api/Orders',
adaptor: new WebApiAdaptor ,
crossDomain: true
});
let grid: Grid = new Grid(
{
dataSource: data,
allowPaging: true,
columns: [
{ field: 'OrderID', headerText: 'Order ID', width: 130, textAlign: 'Right' },
{ field: 'CustomerID', headerText: 'Customer ID', width: 170 },
{ field: 'OrderDate', headerText: 'Order Date', width: 130, format: { type: 'dateTime', format: 'dd/MM/yyyy HH:mm:ss' }, textAlign: 'Right' },
{ field: 'Freight', headerText: 'Freight', width: 160, textAlign: 'Right', format: 'C2' },
{ field: 'ShipCountry', headerText: 'Ship Country', width: 150, textAlign: 'Center' },
],
pageSettings: { pageCount: 3 }
});
grid.appendTo('#Grid'); |