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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Pagination

Thread ID:

Created:

Updated:

Platform:

Replies:

115908 Feb 24,2014 09:20 PM UTC Feb 25,2014 11:46 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Thomas Kiehl
Asked On February 24, 2014 09:20 PM UTC

Hello,

I am trying to set up custom pagination in my C# MVC Grid control. I am using a web service that accepts the starting record number and the number of records per page as parameters. I am having trouble finding examples of how to implement this into my Server Mode cshtml grid builder. Has anyone done this before that can provide some high level samples.

Thanks in advance,
Thomas

Prabhu Sarvesan [Syncfusion]
Replied On February 25, 2014 11:46 AM UTC

Hi Thomas,


Thanks for your interest in Syncfusion products.


We would like to let you know that your requirement to perform custom paging in web service data binding has been achieved. Please, refer the below code snippets to achieve your requirement.


Code Snippets:


[CSHTML]


@(Html.Syncfusion().Grid<WebServiceBinding.Models.Order>("WebServiceBinding")

 

.WebService("/Models/Orders.asmx/RenderOrders")

 

...

 

.TotalRecordCount(100)

 

)

 

[CS]


[WebMethod]

public GridWebService RenderOrders(WebServiceParams webParams)

{

WebParams requestparams = new JavaScriptSerializer().Deserialize<WebParams>(webParams.GridRequestParams);

RequestType requesttype = (RequestType)Convert.ToInt32(requestparams.RequestType);

if (requesttype == RequestType.Paging)

{

IEnumerable pagingdata = OrderDetails(requestparams.StartIndex, requestparams.PageSize);

return pagingdata.GridWebServiceAction<Order>(webParams, totalrecordcount);

}

else

{

IEnumerable data = new NorthwindDataContext().OrdersViews.Take(100).ToList();

return data.GridWebServiceAction<Order>(webParams, totalrecordcount);

}

}

 

private IEnumerable OrderDetails(int Index, int pagesize)

{

int PageSize = pagesize == 0 ? 8 : Convert.ToInt32(pagesize);

IEnumerable data = new NorthwindDataContext().OrdersViews.Skip(Index).Take(PageSize).ToList();

return data;

}


public class WebParams

{

public int RequestType { get; set; }

public int StartIndex { get; set; }

public int PageSize { get; set; }

public string GridID { get; set; }

public string Skin { get; set; }

public string IsGrouped { get; set; }

}


For your convenience we have created a sample depicting your requirement and the same can be download from the below link,


Sample Link:


http://www.syncfusion.com/downloads/support/directtrac/119602/WebServiceBinding473474074.zip


Please let us know if you need any further assistance.


Regards,

Prabhu Sarvesan


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

;