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.

How to restrict the number of rows in a grid page?

Thread ID:

Created:

Updated:

Platform:

Replies:

127696 Dec 2,2016 07:15 PM Dec 5,2016 06:57 AM ASP.NET MVC 1
loading
Tags: Grid
R Brian Lindahl
Asked On December 2, 2016 07:15 PM

I have a grid where the rows can be rather high, so I'd like to limit the number of rows. I tried adding ".PageSettings(a => a.PageSize(5))", but then the grid only says it has one page, even though there are 6 items in the dataset. Is this the right property to use in this case?

Jayaprakash Kamaraj [Syncfusion]
Replied On December 5, 2016 06:57 AM

Hi Brain, 
 
Thank you for contacting Syncfusion Support. 
Yes, you have used correct property of Grid to restrict the number of rows in a grid page. We have created a sample with PageSize as 5 in PageSettings. But we were unable to reproduce the issue at our end. Please refer to the below code example and screenshot. 
 
@(Html.EJ().Grid<SyncfusionMvcApplication29.OrdersView>("FlatGrid") 
            .Datasource(ds => ds.URL("/Grid/DataSource").Adaptor("UrlAdaptor")) 
         .AllowPaging()    /*Paging Enabled*/ 
         .PageSettings(a => a.PageSize(5)) 
        .Columns(col => 
        { 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
.. 
    

        }))

We suspect that you are using UrlAdaptor in Grid. So, we need to handle paging in server-side and also need to calculate data Count before the PerfromSkip() and PerformTake() operations. Please refer to the below code example, knowledge base document and sample. 

https://www.syncfusion.com/kb/4300/server-side-api-for-datamanager-operations

@(Html.EJ().Grid<SyncfusionMvcApplication29.OrdersView>("FlatGrid") 
            .Datasource(ds => ds.URL("/Grid/DataSource").Adaptor("UrlAdaptor")) 
         .AllowPaging()    /*Paging Enabled*/ 
         .PageSettings(a => a.PageSize(5)) 
        .Columns(col => 
        { 
            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
            col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add(); 
            col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Width(75).Add(); 
            col.Field("Freight").HeaderText("Freight").TextAlign(TextAlign.Right).Width(75).Format("{0:C}").Add(); 
    
        })) 
 
GridController.cs 
 
public ActionResult DataSource(Syncfusion.JavaScript.DataManager dm) 
        { 
            IEnumerable Data = new NorthwindDataContext().OrdersViews.ToList(); 
            Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations(); 
 
 
            int count = Data.AsQueryable().Count(); 
            if (dm.Skip != 0) 
            { 
                Data = operation.PerformSkip(Data, dm.Skip); 
            } 
            if (dm.Take != 0) 
            { 
                Data = operation.PerformTake(Data, dm.Take); 
            } 
            return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet); 
        } 

 
If you still facing the problem, Please share the video or screenshot to show the issue. 
 
Regards, 
 
Jayaprakash K. 


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.

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.

;