8000 Whether pageSize and pageNumber can be automatically added to the request body · Issue #142 · superRaytin/paginationjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Whether pageSize and pageNumber can be automatically added to the request body #142
Open
@gogobosco

Description

@gogobosco

By default, paginationjs appends pageSize and pageNumber to the request url, but my backend api only accepts post requests and needs to place these two parameters in the body.
I tried to use beforePaging to obtain pageNumber and modify the data in ajax's beforeSend, but beforePaging is triggered after beforeSend, the page can only be turned to the last page number each time.
May I ask if there is a solution.

      let queryData = {
        //...
        pageSize: 10,
        pageNumber: 1,
      };
      let url = "http://api/page";
      $("#demo").pagination({
        // api 的 url
        dataSource: url,
        ajax: {
          beforeSend: function (e,settings) {
            console.log("beforeSend");
            settings.data=JSON.stringify(queryData);
          },
          type: "POST",          
          data: {},
          ...
        },
        callback: function (data, pagination) {
          //dataContainer.empty();
          console.log(data);
          $tableData.bootstrapTable(’refreshOptions',{ data: data });
        },
        beforePaging: function (pageNum) {
          console.log("beforePaging");
          queryData.pageNumber = pageNum;
        },
        //...
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0