Hi Mahesh,
Thanks for using Syncfusion products.
After rendering the grid, we can use the “dataSource” method to bind data to the grid. Please refer the below code snippet.
//Getting the grid object var gridobj = $("#Grid").data("ejGrid");
//generate new data to bind to grid var newdata = ej.DataManager(window.gridData).executeLocal(ej.Query().skip(skip).take(10));
//After rendering, dataSource method can be used to bind data to the grid gridobj.dataSource(newdata);
|
For your convenience, we have created a simple grid sample which will be bind with different data by clicking a button and a link, and please find the sample from the attachment.
Please let us know if you have any queries.
Regards,
Madhu Sudhanan. P
public ActionResult Data() { var data = EmployeeRepository.GetAllRecords().ToList(); return Json(data, JsonRequestBehavior.AllowGet); <script type ="text/javascript"> function onClick(args) { $.ajax({ url: "/Home/Data", type: "POST", success: function (data) { var gridData = ej.parseJSON(data); var gridModel = $("#Grid").ejGrid("model"); $("#Grid").data("ejGrid") !== undefined && $("#Grid").ejGrid("destroy")// destroy the grid if already rendered gridModel.query = new ej.Query();//clear the queries gridModel.dataSource = gridData;//binding the data to grid gridModel.columns = columns;//binding new column object to grid //re- render the grid with the changed dataSource $("#Grid").ejGrid(gridModel); } }); } |
gridModel.dataSource = ej.DataManager({json:gridData, updateUrl: "/Home/Update2", adaptor: new ej.remoteSaveAdaptor(), offline:false});//binding the data to grid as DataManager gridModel.columns = columns;//binding new column object to grid
//re- render the grid with the changed dataSource $("#Grid").ejGrid(gridModel); |