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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to do a real paging

Thread ID:

Created:

Updated:

Platform:

Replies:

117028 Jul 23,2014 10:06 AM UTC Apr 29,2015 01:27 PM UTC ASP.NET MVC 8
loading
Tags: Grid
James
Asked On July 23, 2014 10:06 AM UTC

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);
        }

Mohammed Farook J [Syncfusion]
Replied On 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


James
Replied On July 30, 2014 11:43 AM UTC

Thank you for your help, problem solved

Mohammed Farook J [Syncfusion]
Replied On 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


Thomas
Replied On 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.

Mahdi Moradi
Replied On April 25, 2015 02:46 PM UTC

Hi,
thank you for your great product,
i was download this sample and when add:
EditSettings(e => e.AllowEditing()
                  .AllowDeleting()
                  .AllowAdding()
                  .EditMode(EditMode.Dialog))
edit dialog load all items in the page.
any suggestion?
(picture is attached)
thank you.

Attachment: pic1_d706da9a.zip

Balaji Marimuthu [Syncfusion]
Replied On 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

Mahdi Moradi
Replied On April 28, 2015 03:20 PM UTC

Thank you so much for your support.
Problem solved.

Best Regards:
M.M

Balaji Marimuthu [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;