We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to do a real paging

we are Currently using version 12.2.0.36  of mvc grid.
How can I do paging in the Controller, like paging 11.4.0.26 version.
Like this, or other methods.
        [AcceptVerbs(HttpVerbs.Post)]
        public ActionResult UserManagerPartial(PagingParams args)
        {
            List<UserDTO> itemList = new List<UserDTO>();
            PagedResult<UserDTO> pageresult = new PagedResult<UserDTO>();
            pageresult = this.GetUserData(args);
            itemList = pageresult.Data;

            return itemList.GridActions<UserDTO>(pageresult.TotalRecords);
        }

6 Replies

MF Mohammed Farook J Syncfusion Team July 24, 2014 10:52 AM UTC

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



JA James July 30, 2014 11:43 AM UTC

Thank you for your help, problem solved


MF Mohammed Farook J Syncfusion Team July 31, 2014 06:47 AM UTC

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



TH Thomas April 24, 2015 11:55 AM UTC

The Code snippet is not 100% correct.

The default for top is 12. In your query you use take(10) instead of take((int)top) thus missing 2 records every time.


BM Balaji Marimuthu Syncfusion Team April 27, 2015 01:03 PM UTC

Hi James,

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


BM Balaji Marimuthu Syncfusion Team April 29, 2015 01:27 PM UTC

Hi James,

Thanks for the response.

Please get back to us if you have any concerns.

Regards,
Balaji Marimuthu

Loader.
Live Chat Icon For mobile
Up arrow icon