Grid Paging in Razor Page

4 posts, 0 answers
  1. Mihail
    Mihail avatar
    3 posts
    Member since:
    May 2014

    Posted 23 Oct 2018 Link to this post

    Hi guys,

    I need some help solving a pagination problem I have with my grid in a Razor page.

    I using 2 Kendo Grids in a Razor page. Second grid (child grid) is a detail grid populated when user expends rows on the parent grid.

    Pagination on the child grid seems not working. It always returns first page. Doing some debugging I observed that even if the page is sent correctly as a string parameter (...&page=3&...) it doesn't get into request.Page property (this is always 1). Please see my UI code below and the screenshots of the my debugging attached.

    Thanks,

    Mihai

     

     

    <script id="template_table" type="text/kendo-tmpl">
        @(Html.Kendo().Grid<TargetTableViewModel>()
                              .Name("grid_target_#=TargetId#")
                              .Columns(columns =>
                              {
                                  columns.Bound(t => t.TableId).Title("ID").Width(100);
                                  columns.Bound(t => t.TableName);
                                  columns.Command(command => command.Destroy()).Width(150);
                              })
                              .ClientDetailTemplateId("template_field")
                              .DataSource(dataSource => dataSource
                                  .Ajax()
                                  .PageSize(25)
                                  .Model(model => model.Id(t => t.TableId))
                                  .Read(read => read.Action("Targets", "MappingPages", new { handler = "TargetTables", targetId = "#=TargetId#" }).Type(HttpVerbs.Get))
                                  .Destroy(delete => delete.Action("Targets", "MappingPages", new { handler = "DeleteTargetTable" }).Data("sendAntiForgery").Type(HttpVerbs.Post))
                                  .Events(events => events.RequestEnd("onRequestEnd('#=TargetId#')"))
                                  .ServerOperation(true)
                              )
                              .Pageable(pageable => pageable.ButtonCount(5))
                              .Sortable()
                              .ToClientTemplate())

    </script>

  2. Mihail
    Mihail avatar
    3 posts
    Member since:
    May 2014

    Posted 23 Oct 2018 Link to this post

    Can an admin move my post to the right location?Thanks.

    https://www.telerik.com/forums/aspnet-core-ui/grid

  3. Georgi
    Admin
    Georgi avatar
    685 posts

    Posted 25 Oct 2018 Link to this post

    Hi Mihail,

    The described behavior is expected as the request is GET. The `page` route value is used by the razor pages engine. The path to raozor page is added to the route diccionary values as a route value with the page key.

    As a workaround I can suggest you to change the type of the request to POST.


    Regards,
    Georgi
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
  4. Mihail
    Mihail avatar
    3 posts
    Member since:
    May 2014

    Posted 26 Oct 2018 Link to this post

    Thanks. That helped.

     

Back to Top