jQuery plug in Easyui setting pageNumber of datagrid causes a solution to the problem of two requests

  • 2021-07-09 06:43:53
  • OfStack

This article illustrates how the jQuery plug-in Easyui sets pageNumber of datagrid to solve the problem of two requests. Share it for your reference, as follows:

1. Problem description:


$('#tb-page-list').datagrid({
    url: '/BisOrderInfo/GetList',
    pageNumber: 2,
    pageSize: 10
});

When the pageNumber is manually set to be greater than or equal to 2, when viewing the requested method, the request will be made twice, and the pageNumber of the second time is equal to 1;

2. Why:

Line 7821-7828 in jquery. easyui. min. js 1.3. 4;

Because the paging control initialization parameters total = = 0 and pageNumber = = 1, the parameters of the first request for page 2 are different from the control initialization parameters, resulting in a second request: _ 5dc (_ 545);

Solution: When the page is refreshed, the total amount of data requested changes and the display of pagebar needs to be updated.

3. Solutions:

Line 7822 (note version 1.3. 4 jquery. easyui. min. js):


_54a.pagination("refresh",{total:data.total});

Amend to read:

_54a.pagination("refresh",{pageNumber:opts.pageNumber||_54b.pageNumber,total:data.total});

More readers interested in jQuery can check the topics of this site: "Summary of jQuery Extension Skills", "Summary of jQuery Common Plug-ins and Usage", "Summary of jQuery Drag Effects and Skills", "Summary of jQuery Table (table) Operation Skills", "Summary of Ajax Usage in jquery", "Summary of jQuery Common Classic Special Effects", "Summary of jQuery Animation and Special Effects Usage" and "Summary of jquery Selector Usage"

I hope this article is helpful to everyone's jQuery programming.


Related articles: