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'));
|
@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> |