[component.html]
<ejs-grid #grid [dataSource]='data' allowPaging='true' [editSettings]='pageSettings'>
<e-columns>
<e-column field='OrderID' isPrimaryKey='true' headerText='Order ID' width='120' textAlign='Right'></e-column>
. . .
</e-columns>
</ejs-grid>
[component.ts]
@Component({
selector: 'ej2-griddatabind',
templateUrl: 'remote-data.html'
})
export class DataBindingComponent implements OnInit {
. . .
ngOnInit(): void {
this.data = new DataManager({ url: 'Home/GetOrderData', updateUrl: 'Home/PerformUpdate’, removeUrl: 'Home/PerformDelete’, insertUrl: 'Home/PerformInsert', adaptor: new UrlAdaptor });
}
} |
//Provide grid datasource
public ActionResult GetOrderData()
{
. . .
return Json(new { result = result, count = result.Count },JsonRequestBehavior.AllowGet);
}
public ActionResult PerformInsert([FromBody]CRUDModel<OrdersDetails>
param)
{ //Perform insertion
. . .
return Json(param.value);
}
public ActionResult PerformUpdate([FromBody]CRUDModel<OrdersDetails>
param)
{
//Perform update
. . .
return Json(param.value); }
public ActionResult PerformDelete([FromBody]CRUDModel<OrdersDetails>
param)
{
//Perform delete
. . .
return Json(param.Key);
}
|