public ActionResult Update(OrdersDetails value)
{
...
return Json(value);
}
public render() {
return (<div className='control-section'>
<GridComponent id="Grid">
<ColumnsDirective>
<ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right'></ColumnDirective>
<ColumnDirective field='CustomerName' headerText='Customer Name' width='150'></ColumnDirective>
<ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' />
<ColumnDirective field='ShipCountry' headerText='Ship Country' width='150'></ColumnDirective>
</ColumnsDirective>
</GridComponent>
</div>)
}
ajax = new Ajax({
url: "/Home/DataSource",
type: "POST"
}).send().then((data: any) => {
var grid = (document.getElementById("Grid") as any).ej2_instances[0]; // Grid instance
grid.dataSource = new DataManager({// provided the dataSource to the Grid through the remoteSaveAdaptor
json: JSON.parse(data),
adaptor: new RemoteSaveAdaptor()
});
}) |
Hi Ali Rahighi,
Query #1: but how to retrieve data from server ?
You can collect the data’s from the server through the ajax request. After that in the ajax success event, you can provide the ajax result to the Grid dataSource through the remoteSaveAdaptor. Please refer the following code snippet,
public render() {return (<div className='control-section'><GridComponent id="Grid"><ColumnsDirective><ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right'></ColumnDirective><ColumnDirective field='CustomerName' headerText='Customer Name' width='150'></ColumnDirective><ColumnDirective field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right' /><ColumnDirective field='ShipCountry' headerText='Ship Country' width='150'></ColumnDirective></ColumnsDirective></GridComponent></div>)}ajax = new Ajax({url: "/Home/DataSource",type: "POST"}).send().then((data: any) => {var grid = (document.getElementById("Grid") as any).ej2_instances[0]; // Grid instancegrid.dataSource = new DataManager({// provided the dataSource to the Grid through the remoteSaveAdaptorjson: JSON.parse(data),adaptor: new RemoteSaveAdaptor()});})
We have prepared the sample with this code and you can find that sample in the below link,
Sample: http://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication11663104698.zip
Query #2: why data format of the CRUD request always is like
From your query we found that you need to send only the edited values to server. But By default, Grid will send the edited values to server by the default format. If you need to change this format, then you need to customize this format in client side. So please provide the your exact requirement (i.e why you need to send only the edited values to server?) to us. This will help us to provide the solution as early as possible.
Regards,Hariharan