- Home
- Forum
- ASP.NET MVC
- How to do a real paging
How to do a real paging
Hi James,
Thanks for using Syncfusion products,
Based on your Request ,
We have created a sample for paging action in Ej MVC Grid (12.2.36 version) . Please follow the below code snippet.
|
[controller] public ActionResult DataSource([Bind(Prefix = "$skip")]int? skip, [Bind(Prefix = "$top")]int? top)
{
var DataSource = OrderRespositary.GetAllRecords();
var result = DataSource.Skip((int)skip).Take(10).ToList();
var count = DataSource.Count();
return Json(new { d =
new { results = result, __count = count }
}, JsonRequestBehavior.AllowGet);
}
[View
Model] @model string
@(Html.EJ().Grid<servesidePaging.OrdersView>("FlatGrid")
.Datasource(ds => ds.URL("Home/DataSource")) .AllowPaging()
/*Paging Enabled*/ ) |
Sample:
servesidePaging.zip
Please let us know if have any queries,
Regards,
J.Mohammed Farook
Hi James,
Thanks for your update.
Please get back if you require
further assistance. We will be glad to assist you.
Regards,
J.Mohammed
Farook
Sorry for the inconvenience caused.
We have analyzed your queries and please find the response.
Query:#1 The default for top is 12. In your query you use take(10) instead of take((int)top) thus missing 2 records every time.
Datamanager parameter is a server side method, which contains all the required values for performing server side operations. So we can use dm.Take, in Take method to get the default number of records and also can change the number of records by mentioning the integer values in Take method. Please find the below code snippet:
public ActionResult Data(DataManager dm) { var DataSource1 = OrderRepository.GetAllRecords(); DataResult res = new DataResult(); res.result = DataSource1.Skip(dm.Skip).Take(dm.Take).ToList(); res.count = DataSource1.Count(); return Json(res, JsonRequestBehavior.AllowGet); |
Please refer the online documentation for more information:
http://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations
Query:#2 edit dialog load all items in the page. any suggestion?
We suspect that you are not using any Primary key column in the Grid columns. So we suggest you to set the IsPrimaryKey property as true to set primary key column in Grid columns. Because the editing operations in Grid are performed by based on the primarykey column. Please refer the following code snippet.
@(Html.EJ().Grid<OrdersView>("Editing") .Datasource((IEnumerable<object>)ViewBag.dataSource) .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Dialog); }) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Width(90).Add(); col.Field("CustomerID").HeaderText("Customer ID").Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("minlength", 3)).Add(); col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).EditType(EditingType.Numeric).Format("{0:C}").Add(); col.Field("ShipCountry").HeaderText("Ship Country").EditType(EditingType.Dropdown).Width(85).Add(); col.Field("ShipCity").HeaderText("Ship City").Width(90).Add(); }) |
Please refer the online documentation for more information: http://www.syncfusion.com/kb/2675/cant-edit-any-row-except-the-first-row-in-grid
Please let us know if you have any queries.
Regards,
Balaji Marimuthu
Thanks for the response.
Please get back to us if you have any concerns.
Regards,
Balaji Marimuthu
- 8 Replies
- 4 Participants
-
CO cole
- Jul 23, 2014 10:06 AM UTC
- Apr 29, 2015 01:27 PM UTC