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