var url = "http://localhost:5000/api/Persona";var data = new ej.data.DataManager({ url : url, crudUrl: url, adaptor: new ej.data.RemoteSaveAdaptor(), offline: true
|
<div>
@Html.EJS().Grid("Grid").DataSource(dataManager => { dataManager.Json(ViewBag.datasource).UpdateUrl("/Home/Update").Adaptor("RemoteSaveAdaptor"); }).Columns(col =>
{
col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Width("120").ValidationRules(new { required = true }).TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add();
. . . .
}).AllowPaging().AllowSorting().AllowFiltering().PageSettings(page => page.PageCount(2)).EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).Toolbar(new List<string>() {"Edit", "Update", "Cancel" }).Render()
</div>
|
|
var dataSource = @Html.Raw(Json.Encode(ViewBag.DataSource));
var data = new ej.data.DataManager({
json: dataSource,
updateUrl:"Update",
adaptor: new ej.data.RemoteSaveAdaptor()
});
var grid = new ej.grids.Grid({
dataSource: data,
editSettings: { allowEditing: true, mode: 'Normal' },
toolbar: [ 'Edit', 'Update', 'Cancel'],
. . . . . .
columns: [
. . . . . .
],
});
grid.appendTo('#Grid'); |
|
ajax.onSuccess = (data: any) => {
if (grid.element !== undefined) {
// need to bind the Grid dataSource as result and count format .i.e., {result: data, count : total count} . In count need to pass whole dataSource count and result binding only current view record (12 based on your pageSize)
grid.dataSource = {result: JSON.parse(data).slice(gquery.skip, gquery.take * grid.pageSettings.currentPage), count : JSON.parse(data).length};
// if it is CRUD action means you call endEdit method
grid.endEdit();
}
};
|