- Home
- Forum
- React - EJ 2
- How to set default paging to show all rows
How to set default paging to show all rows
Hi,
Is there anyway to set default paging of grid to show all rows instead of 10 rows / page?
Thanks
SIGN IN To post a reply.
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.
[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'));
|
Please get back to us if you need any further assistance on this.
Regards,
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.
Sample : https://www.syncfusion.com/downloads/support/directtrac/general/ze/mvc_single_page1791370816.zip
|
@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
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
AL Albert
- Aug 11, 2019 08:27 PM UTC
- Jan 21, 2020 10:34 AM UTC