PagingToolbar does not work - extjs

I am using PagingToolbar to filter my result search, I want do display 20 result per page, but in my grid still display all records.
The bbar in my grid
bbar: Ext.create('Ext.PagingToolbar',
store: store,
pageSize: 20,
displayInfo : true,
plugins: Ext.create('Ext.ux.ProgressBarPager', {})
}),
My Store
Ext.define('Mystore', {
extend: 'Ext.data.Store',
model: 'Mymodel',
pageSize: 20,
autoLoad: true,
remoteSort: true,
proxy: {
type: 'rest',
url: 'search',
reader: {
type: 'json',
root: 'root',
idProperty: 'id'
},
writer: {
type: 'json',
writeAllFields: true
}
}
});
Anybody could help me ??
Thanks.

Your /search REST service that provides the data for the store needs to support the start, limit, and/or page parameters so that the store can request a single page of results at a time.
To support the limit parameter, your service must limit the number of returned results to no more than the count specified in that parameter. You'd typically implement that by passing the limit value through to the database query you're using to provide the results.

Your Store must contain this parameter with start and limit and your backend need to use these parameters.
baseParams : {
start:0, limit:20
}
In java backend,
String startPage = request.getParameter("start");
String limits = request.getParameter("limit");
It's kind of filter for your grid.

Related

How to implement the frontend paging using Extjs 7.0

I know how to do it in the store with the backend paging. But would you please give the suggestions about how to do it with the frontend paging?
You can use a memory proxy and set the config property enablePaging to true.
Example:
var store = Ext.create('Ext.data.Store', {
autoLoad: true,
pageSize: 5,
data: data,
proxy: {
type: 'memory',
enablePaging: true,
reader: {
type: 'json',
rootProperty: 'people'
}
}
});
I created a fiddle for this:
https://fiddle.sencha.com/#view/editor&fiddle/3c6e

Paging on grid panel (extjs)

I am following the code in the link below to page data on a Ext.grid.Panel without success. Data is rendered altogether in the panel without paging. Apparently, the paging toolbar has no data to display but it is correctly configured to the store that has the data and it is hanging as an item of the grid.
I have copied the exact configurations of store and grid from the example below but nothing happened. Why is the data not being paged?
http://jsfiddle.net/jardalu/TE4ah/
This is my store which is linked to the grid and the paging toolbar:
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
pageSize: 50,
remoteSort: true,
storeId: 'Users',
autoLoad: false,
model: 'AICWeb.model.User',
sortOnLoad: false,
proxy: {
type: 'ajax',
type: 'localstorage',
simpleSortMode: true,
reader: {
type: 'xml'
}
},
sorters: {
property: 'email'
}
}, cfg)]);
}
If you are using localstorage you need to implement the PagingMemoryProxy. This should be the only type on the proxy config, and enable the paging config:
proxy: {
type: 'pagingmemory'
enablePaging: true,
...
}

Search in combobox with pagination extjs

Hello i'm trying to do search in combobox.It's working but search only in current page i'm using pagination with search too i need to search in all pages not current page only
Any suggestion
{
xtype: 'combo',
fieldLabel: 'Organization Id',
name: 'company_id',
displayField:'name_en',
valueField:'id',
store: Ext.create('UserApp.store.PicklistList', {
autoLoad: true,
fields: ['id', 'name_en', 'name_se'],
proxy:{
type:'ajax',
api: {
read:'picklist/listitems'
},
reader: {
type: 'json',
root: 'root',
successProperty: 'success'
},
extraParams:{
table :'table_name'
}
}
}),
editable: true,
autoSelect: false,
selectOnFocus:true,
typeAhead:true,
minChars:2,
queryMode: 'local',
mode: 'local',
pageSize: 25,
width:370,
allowOnlyWhitespace: false,
regex: /[a-zA-Z0-9]+/, // avoid to empty data only
})
I'm using combobox with queryMode : 'remote' and doing a search withing combobox for matches. I'm doing a 'contains' search - meaning it looks for matches anywhere in the result string not just beginning and also it searches for values not only in current page but in the entire resultset. I'm using extjs 4.0.7 and i achived it by overriding doQuery method.
`doQuery: function(queryString, forceAll) {
this.expand();
this.store.clearFilter(!forceAll);
if(this.queryMode == 'remote') {
this.store.load({
params: this.getParams(queryString)
});
}
if (!forceAll) {
this.store.filter(this.displayField, new RegExp(Ext.String.escapeRegex(queryString), 'i'));
}
}`
your store needs to be setup for pagination
your server needs to handle pagination correctly based on the parameters received from the store's proxy. The proxy will send up querystring parameters like ?page=1&start=0&limit=25, and your server needs to return only 25 (for example) records and a total parameter.
{"total":101,"data":[{model data}, {model data}, ...]}
despite the documentation, the pageSize property in combobox is actually a boolean, turning pagination on if 1 or greater.

baseParam for extjs paging

I am using datefields and comboboxes to make a selection to load a store. When the store is loaded into a grid i have a paging toolbar. So far so good.
When the user clicks on the next page the pagingtoolbar is not sending the data from the datefields with it. I read something about baseparams but this aint working.
I use EXTJS 4.1
This is my store:
NL.commListDetails = new Ext.data.Store({
model: 'stepDetails',
pageSize: 20,
loadMask: false,
sortOnLoad: true,
proxy: {
type: 'ajax',
url: detailURL,
startParam: '',
limitParam: '',
pageParam: '',
reader: {
type: 'json',
root: 'slaevents',
totalProperty: 'slaevents[0].totalCount'
}
},
baseParams: {fromDate:NL.startDate},
autoLoad: false
});
And here is the paging toolbar
bbar: Ext.create('Ext.PagingToolbar', {
store: NL.commListDetails,
displayInfo: true,
displayMsg: 'Displaying record {0} - {1} of {2}',
emptyMsg: "No records to display",
}),
I need to send fromDate, endDate with the paging. Both available in NL.startDate and NL.endDate. How can i send this when i click on next page?
There is no configuration of baseParams for the store. To send extra params you should use the extraParams configuration for the ajax proxy.
proxy: {
type: 'ajax',
....
extraParams: {fromDate:NL.startDate},
..
},
Also defining the params when creating the store will mean they are static, so they won;t change if you modify the datefields or comboboxes...
So a fix will be to listen to the change event on the combobox or datefield and reset the extra params:
change: function(this,value){
NL.commListDetails.getProxy().getExtraParams().comboName = value;
}
Edit
I stand corrected. There is a baseParams but it's on elementloader and that is called only when load is directly invoked, which i think is not the case for the paging toolbar which uses loadPage. I might be wrong on this one, but i'm using extraparams and it works ok.

Extjs Grid Filter - Dynamic ListFilter

I am trying to implement Ext.ux.grid.filter.ListFilter using a data store (rather than a hardcoded list) as covered here in the ExtJS 4 API. The data comes in fine and I see a filter option on this column but it just says "Loading..." where the filter options are supposed to be:
I am pretty sure I have this configured as per the API specs but have not had any luck with this. Has anyone implemented this correctly?
The store I use to get the filter options is set up like this:
// get the levels for filtering
var levelStore = Ext.create('Ext.data.Store', {
fields: ['levels'],
proxy: {
type: 'ajax',
url: '../json?queryName=levels',
reader: 'json'
},
autoLoad: true
});
I implemented the filter config in the column like so:
{
header: 'Level',
dataIndex: 'levels',
width: 160,
sortable: true,
filter: {
type: 'list',
store: levelStore
}
Some thoughts I had:
Do I need my filter option data store to have a specific column title, like "name" instead of "level"?
Is this trying to get the store options before they are loaded from ajax, and there is some unspecified way of telling it to load these filter options after the ajax is returned?
Do I need to implement my filter configuration separate from the column config to use this one? (all my other filter configurations, are done right in the column config and seem to work fine)
EDIT:
The json response looks something like this, not sure if it is causing the trouble:
[{"levels":"Level 1"},{"levels":"Level 2"},{"levels":"Level 3"}]
I have it resolved now. I ended up configuring the filter with an empty options array options: [] and then put a callback on the store that adds the filter options to the empty options array. Like this:
The column model (with filter config):
{
header: 'Level',
dataIndex: 'levels',
itemId: 'levels',
width: 160,
sortable: true,
filter: {
type: 'list',
options: [],
phpMode: true,
}
}
The store:
var levelStore = Ext.create('Ext.data.Store', {
fields: ['levels'],
proxy: {
type: 'ajax',
url: '../json?queryName=levels',
reader: 'json'
},
autoLoad: {
callback: function() {
grid.getView().getHeaderCt().child('#levels').initialConfig.filter.options = levelStore.collect('levels');
}
}
});
('grid' is the variable that I named my grid with the filters)
I have the same when using ExtJs 4.0.2a. Ive find whatautoLoadmust false for store and some patch toExt.ux.grid.menu.ListMenu`.
The store:
var levelStore = Ext.create('Ext.data.Store', {
fields: ['levels'],
proxy: {
type: 'ajax',
url: '../json?queryName=levels',
reader: 'json'
},
autoLoad: false
});
And replace show method in ext-4.0.2a/examples/ux/grid/menu/ListMenu.js with:
show : function () {
var lastArgs = null;
console.debug('show filter menu');
return function(){
if (this.loadOnShow && !this.loaded) {
this.store.load();
}
if(arguments.length === 0){
this.callParent(lastArgs);
} else {
lastArgs = arguments;
this.callParent(arguments);
}
};
}()
This is simple
filter: {
type: 'list',
options: levelStore.collect('levels')
}

Resources