<EjsButton OnClick="@Press"> LOG ME </EjsButton>
Current page__ @CurrentPage
Page size__ @PageSize
<EjsGrid @ref="DefaultGrid" @ref:suppressField DataSource="@Orders" AllowPaging="true" Height="200">
<GridEvents OnLoad="Load" TValue="Order"></GridEvents>
<GridPageSettings PageCount="2" PageSize="@PageSize" CurrentPage="@CurrentPage" PageSizes="@PageSizes"></GridPageSettings>
...
</EjsGrid>
@code{
private EjsGrid<Order> DefaultGrid;
public int GridHeight;
public List<Order> Orders { get; set; }
public int CurrentPage = 3;
public int PageSize { get; set; }
public object PageSizes;
...
public void Load(object args)
{
var RowHeight = 37; //height of the each row
Int32.TryParse(this.DefaultGrid.Height, out GridHeight); //grid height
var PageSizee = (this.DefaultGrid.PageSettings as GridPageSettings).PageSize; //initial page size
decimal PageResize = ((GridHeight) - (PageSizee * RowHeight)) / RowHeight; //new page size is obtained here
PageSize = PageSizee + (int)Math.Round(PageResize);
CurrentPage = 3;
PageSizes = true;
}
}
|
|
<h1>CurrentPage: @Pager</h1>
<h1>PageSize: @PagerCount</h1>
<SfButton OnClick="Clik">Get Page Details</SfButton>
<GridColumns>
<GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120"></GridColumn>
<GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>
<GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>
<GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>
</GridColumns>
</SfGrid>
@code{
SfGrid<Order> Grid { get; set; }
public List<Order> Orders { get; set; }
public int Pager;
public int PagerCount;
. . . .. . .
public void Clik()
{
Pager = Grid.PageSettings.CurrentPage;
PagerCount = Grid.PageSettings.PageSize;
}
}
|