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

How to set default paging to show all rows

Thread ID:

Created:

Updated:

Platform:

Replies:

146627 Aug 11,2019 08:27 PM UTC Jan 21,2020 10:34 AM UTC React - EJ 2 3
loading
Tags: Grid
Albert
Asked On August 11, 2019 08:27 PM UTC

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

Pavithra Subramaniyam [Syncfusion]
Replied On 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. 
 
[index.js] 
export class Paging extends SampleBase { 
constructor() { 
        super(...arguments); 
        this.flag = true; 
    } 
  dataBound(e){ 
    if(this.flag) 
    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 }}> 
                        <ColumnsDirective> 
                            <ColumnDirective field='OrderID' headerText='Order ID' width='120' textAlign='Right'></ColumnDirective> 
                               .   .   . 
                        </ColumnsDirective> 
                        <Inject services={[Page]}/> 
                    </GridComponent> 
                </div> 
            </div>); 
    } 
} 
 
render(<Paging />, document.getElementById('sample')); 
 
 
                               https://ej2.syncfusion.com/react/documentation/api/grid/pageSettingsModel/#pagesize 
 
 
Please get back to us if you need any further assistance on this. 
 
Regards, 
Pavithra S. 


Ekaterina Balaban
Replied On January 20, 2020 11:41 PM UTC

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

Dhivya Rajendran [Syncfusion]
Replied On 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("Freight").HeaderText("Freight").Width("120").Format("C2").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).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() 
 
<script> 
    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 
    }  
    } 
</script>  

Please get back to us if you need further assistance. 

Regards, 
R.Dhivya              


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

Live Chat Icon For mobile
Live Chat Icon