简体   繁体   中英

Nonfactors mvcgrid paging problems

Ive just started using NonFactors.Grid.Mvc6 -Version 6.2.4. Ive got its basic functionality working and Im able to retrieve data from my serverside code (.net core 5). I want to implement paging but Im only able to get it to page through the dataset ive received on the clientside. For example, Ive returned 5 rows from the database, the grid only allows me to page through those 5 items. I cant find any documentation (or examples) of using ajax calls to retrieve the data in pages (specifying the current page and number of rows). This is of no use in the real world so the grid must be capable of this somehow (hopefully), but there is nothing documented. Has anyone managed to do this? Id really appreciate some examples, the documentation is pretty poor

I have the same problem, if I want to use the paging from the backend

Code example

.Pageable(pager =>
{
    pager.ShowPageSizes = true;
    pager.PageSizes = Model.Paging.PageSizes;
    pager.PagesToDisplay = Model.Paging.PagesToDisplay;

    pager.CurrentPage = Model.Paging.CurrentPage;
    pager.RowsPerPage = Model.Paging.RowsPerPage;

    pager.TotalRows = Model.Paging.TotalRows;
})

You can set the TotalRows value, but it will be recalculated for the _Pager.cshtml view based on the Rows.

public virtual IQueryable<T> Process(IQueryable<T> items)
    {
        TotalRows = items.Count();

My workaround, add/modify the following line to the _Grid.cshtml file:

    @if (Model.Pager != null)
{
    Model.Pager.TotalRows = Model.Pager.PagesToDisplay * Model.Pager.RowsPerPage;

    @await Html.PartialAsync(Model.Pager.PartialViewName, Model.Pager)
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM