|
@Component({
selector: 'my-app',
template: `<ejs-grid #grid [dataSource]='data' [allowSorting]='true' [toolbar]='toolbar' [allowFiltering]='true' [allowPaging]='true' >
<e-columns>
<e-column field='OrderID' headerText='Order ID' textAlign='right' width=120></e-column>
<e-column field='CustomerID' headerText='Customer ID' width=150></e-column>
<e-column field='Freight' headerText='Freight' width=150></e-column>
<e-column field='ShipCity' headerText='Ship City' width=150></e-column>
</e-columns>
</ejs-grid>`
})
export class AppComponent implements OnInit {
public data: DataManager | Object[];
public toolbar: ToolbarItems[];
ngOnInit(): void {
this.toolbar = ['Search'];
this.data = new DataManager({
url: "/Home/DataSource",
adaptor: new UrlAdaptor
});
}
|
|
public ActionResult DataSource(OrderRepository.DataManager dm)
{
OrderRepository.Result data = OrderRepository.GetAllRecords(dm);
return Json(data, JsonRequestBehavior.AllowGet);
}
. . .
orders = (from ord in new NorthwindDataContext().Orders
select new EditableOrder
{
OrderID = ord.OrderID,
Freight = ord.Freight,
CustomerID = ord.CustomerID,
ShipCity = ord.ShipCity
}).Where(search).Where(filter).ToList();
|