Implementation of paged query with conditional EXTJS3

Source: Internet
Author: User

The comrades who use ExtJS must know Gridpanel. Artifact General, very convenient to display the table type of data, such as God horse user list, product list, Sales Single table, XXXX list and so on. By querying the data from the database and displaying it as a list, we should have thought of searching for that data.
The simplest way to search is to reload the store associated with Gridpanel, and save the search results, but the initial implementation of the search has destroyed the original paging feature of Gridpanel.

Reason:
After the store is re-loaded with data, Pagingtoolbar does not work because ExtJS defaults to server-side paging, which is sending a request with the start, limit parameter, and paging through the SQL statement (remember that local paging is also achievable and ready to be sorted).


Workaround:
Take advantage of the store's "Beforeload" event and the Baseparams property. Beforeload is triggered before the store loads data, so-called Baseparams, is the store every time the HTTP request will take the parameters, originally it is an object form, the request will be converted to parameters of the string.

//Ledger accounting interval, time period, account, with four variables to store query conditionsvarSe_period;varSe_subject;varSe_starttime;varSe_endtime;//Jsonstore for storing itemized accountsvarSubsidiarystore =NewExt.data.JsonStore ({fields: ["Date", "Voucherno", "explanation", "debit", "credit"], url:' Subsidiaryaction!getsubsidiary.action ', Totalproperty:' Sum ', Root:' Subsidiary ', listeners: {"Beforeload":function(store) {Store.baseparams={starttime:se_starttime, endtime:se_endtime,                Subject:se_subject, Period:se_period} }        }});

Inquire:

//a loading method implemented on a button that is used for lookupsbuttons: [{text:' Load ', Handler:function() {se_period= Searchpanel.findbyid (' Se_period '). GetValue (); Se_subject= Searchpanel.findbyid (' Se_subject '). GetValue (); Se_starttime= Searchpanel.findbyid (' Se_starttime '). GetValue (); Se_endtime= Searchpanel.findbyid (' Se_endtime '). GetValue (); Subsidiarystore.load ({params: {start:0, Limit:pagesize}}); }}]

In this way, when the store loads data, it will submit the query conditions at the same time, the background normal access to those parameters, make a judgment, query conditions for the empty time of the page to take all the data on it,

Implementation of paged query with conditional EXTJS3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.