or
<script type="text/javascript"> $(document).ready(function () { var transport = { read: { contentType: "application/json; charset=utf-8", type: "POST", dataType: "json", url: "JQueryGrid/Grid_Read" }, update: { url: "JQueryGrid/Grid_Update", contentType: "application/json; charset=utf-8", type: "POST" }, create: { url: "JQueryGrid/Grid_Create", type: "POST" }, destroy: { contentType: "application/json; charset=utf-8", url: "JQueryGrid/Grid_Destroy", type: "POST", dataType: "json" }, parameterMap: function (data, operation) { return kendo.stringify(data); } }; var dataSource = new kendo.data.DataSource({ transport: transport, batch: true, pageSize: 30, schema: { model: { id: "PersonalID", fields: { PersonalID: { type: "number", editable: false }, FirstName: { type: "string", validation: { required: true} }, LastName: { type: "string", validation: { required: true} }, DOB: { type: "date" } } } } }); $("#grid").kendoGrid({ dataSource: dataSource, height: 250, filterable: true, type: "odata", sortable: true, pageable: true, editable: "inline", toolbar: ["create"], columns: [ { field: "PersonalID", filterable: false, width: 100 }, { field: "FirstName", title: "First Name", width: 200 }, { field: "LastName", title: "Last Name", width: 200 }, { field: "DOB", title: "Date born", width: 100, format: "{0:MM/dd/yyyy}" }, { command: ["edit", "destroy"], title: " ", width: "210px" } ] }); }); </script>
public ActionResult Grid_Read() { var personalDtos = _personalService.GetAllPersonalByFilters(1, string.Empty); return Json(personalDtos); } [HttpPost] public ActionResult Grid_Update(PersonalDto dto) //<--- comes empty { var personalDtos = _personalService.GetAllPersonalByFilters(1, string.Empty); return Json(personalDtos); } [HttpPost] public ActionResult Grid_Create(PersonalDto dto)//<--- comes empty{ var personalDtos = _personalService.GetAllPersonalByFilters(1, string.Empty); return Json(personalDtos); }
var grid = Html.Telerik().Grid<StaffRoleGridItem>() .Name("OStaffRoles") .DataBinding(db => { db.Ajax() .Select("_ListUsers", "Ajax", new { type = Model.Type }); }) .Columns(c => { c.Bound(o => o.Id).Hidden(); c.Bound(o => o.Name).Title("User/Group Name"); c.Bound(o => o.Role).Title("Role in Project"); }); if ((POModel.ViewMode)ViewBag.Mode == PMOBaseModel.ViewMode.CREATE) { grid .DataKeys(keys => keys.Add(o => o.Id)) .ToolBar(cmd => { cmd.Insert().ButtonType(GridButtonType.Text).ImageHtmlAttributes(new { style = "margin-left: 0" }).Text("Add New Role"); }) .DataBinding(db => { db.Ajax() .Insert("_InsertUser", "Ajax", new { type = Model.Type }) .Update("_EditUser", "Ajax", new { type = Model.Type }) .Delete("_DeleteUser", "Ajax", new { type = Model.Type }); }) .Columns(c => { c.Command(cmd => { cmd.Edit().ButtonType(GridButtonType.Text); cmd.Delete().ButtonType(GridButtonType.Text); }).Width(190); }) .Editable(e => e.Mode(GridEditMode.InLine)) .ClientEvents(ev => ev.OnEdit("onRoleEdit")); } grid.Render();$("#grid").kendoGrid({ dataSource: { type: "json", transport: { read: "http://localhost:8888/mysite/xml/sample.json" }, schema: { model: { fields: { id: { type: "number" }, data: { type: "json" } } } }, pageSize: 5 }, height: 250, pageable: true, columns: [{ field:"id", title: "Record ID", filterable: false }, { field: "data", title: "Data String" } ], });[ { "id":0, "data":[ { "source":"Lotus Domino XML Mail", "title":"Mr SYDPER", "path":"/NSF//Marketing/Travel Itininery" } ] }, { "id":1, "data":[ { "source":"Lotus Domino XML Mail", "title":"Re: CMI statement for", "path":"/Marketing/Mark" } ] }]
dataSource = new kendo.data.DataSource({ type: "json", serverPaging: true, serverSorting: true, serverFiltering: false, error: function (e) { // display custom error }, ...});success: function(data) { var that = this, options = that.options, hasGroups = options.serverGrouping === true && that._group && that._group.length > 0; data = that.reader.parse(data); if (that._handleCustomErrors(data)) { // should dequeue request! // that._dequeueRequest(); return; } ... that._dequeueRequest(); // only called if any data is retrived that._process(that._data);}