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 set default paging to show all rows

Is there anyway to set default paging of grid to show all rows instead of 10 rows / page?

3 Replies

PS Pavithra Subramaniyam Syncfusion Team August 12, 2019 07:13 AM UTC

Hi Afshin 
Thanks for contacting Syncfusion Support. 
You can set the pageSettings.pageSize property to show all the records in one page inside the “dataBound” event of Grid component. Please refer to the below code example, documentation link and sample link for more information. 
export class Paging extends SampleBase { 
constructor() { 
        this.flag = true; 
    this.gridInstance.pageSettings.pageSize =this.gridInstance.pageSettings.totalRecordsCount; 
    this.flag = false 
    render() { 
        return (<div className='control-pane'> 
                <div className='control-section'> 
                    <GridComponent dataSource={data} 
                    ref={grid => this.gridInstance = grid} allowPaging={true} height={365} dataBound={this.dataBound.bind(this)} pageSettings={{ pageCount: 4 }}> 
                            <ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right'></ColumnDirective> 
                               .   .   . 
                        <Inject services={[Page]}/> 
render(<Paging />, document.getElementById('sample')); 
Please get back to us if you need any further assistance on this. 
Pavithra S. 

PG Pranav Gaikwad January 20, 2020 11:41 PM UTC

How would you do the same for the ASP.NET MVC grid component? Thank you!

DR Dhivya Rajendran Syncfusion Team January 21, 2020 10:34 AM UTC

Hi Ekaterina, 

Thanks for contacting syncfusion support 

Query  : How would you do the same for the ASP.NET MVC grid component? 
As per your requirement, we have created a sample in ASP.NET MVC.  We have bind dataBound event for grid, In the databound event we have changed the pagesize with respect to the total records count. Please refer the sample and code example for more information. 

@Html.EJS().Grid("grid").DataSource((IEnumerable<object>)ViewBag.DataSource).Height(400).Columns(col => 
    col.Field("OrderID").HeaderText("Order ID").Width("120").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
    col.Field("CustomerID").HeaderText("Customer Name").Width("150").Add(); 
    col.Field("OrderDate").HeaderText("Order Date").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Format("yMd").Add(); 
    col.Field("ShipCountry").HeaderText("Ship Country").Width("120").Add(); 
}).AllowPaging().EditSettings(edit => { edit.AllowAdding(true).AllowEditing(true).AllowDeleting(true).Mode(Syncfusion.EJ2.Grids.EditMode.Normal); }).DataBound("DataBound").Render() 
    var flag = true; 
    function DataBound(args) { 
        var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0]; 
        if (flag) { 
            grid.pageSettings.pageSize = grid.pageSettings.totalRecordsCount; 
        flag = false 

Please get back to us if you need further assistance. 


Live Chat Icon For mobile
Up arrow icon