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
close icon

Custom Pagination

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

1 Reply

PS Prabu Sarvesan Syncfusion Team 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


Loader.
Live Chat Icon For mobile
Up arrow icon