PDA

View Full Version : Need some help integrating column filters in a grid



openminds2010
8 Apr 2010, 4:47 AM
Hello community,

as you can see, that's my first post in here \:D/

Just started with ExtJS and now I am at a point, where I didn't found some help in example codes or elsewhere. So I try the forum.

I create a grid by the followig code:


Ext.namespace('anExtension');

anExtension = Ext.extend(Ext.grid.GridPanel, {
constructor: function(config) {

config = Ext.apply({
title: 'Test',
region: 'center',
viewConfig: {
forceFit: true
},
loadMask:true,
store: store,
columns: anExtension.MainColumns,
}, config);

anExtension.superclass.constructor.call(this, config);
},
});
The grid is rendered and everything works fine. Now, I try to add some column filters. Injected the necessary js files and try to add filters like this:


var filters = new Ext.ux.grid.GridFilters({
encode: false,
local: true,
filters: [{
type: 'string',
dataIndex: 'title'
}]
});
then I add



plugins:[filters]
to the grid config. But I failed. Just got the following error:

Ext.ux.grid.GridFilters is undefined in GridFilters.js (459):
return Ext.ux.grid.filter[type.substr(0, 1).toUpperCase() + type.substr(1) + 'Filter'];

Can anyone give me a clue on how I can add filters in my Extension grid?
Thanks for your help!

regards
Mario

Animal
8 Apr 2010, 4:54 AM
The plugin needs fixing for 3.2.0.

The "type" is no longer a String.

Should have been done... slapped wrists...

openminds2010
8 Apr 2010, 5:18 AM
Hi Animal,

wow, your're pretty fast. Thanks for your answer. Unfortunatelly I am using still the 3.0 Version and at the moment there is no way to update this.

Is the plugin not working with 3.0? I thought the problem was my inplementation of the filters not the plugin, isn't it?

regards
Mario

openminds2010
8 Apr 2010, 8:05 AM
To prevent all misunderstandings I post the complete code again:




Ext.namespace('anExtension');

anExtension = Ext.extend(Ext.grid.GridPanel, {
constructor: function(config) {

var filters = new Ext.ux.grid.GridFilters({
encode: false,
local: true,
filters: [{
type: 'string',
dataIndex: 'title'
}]

});
config = Ext.apply({
title: 'Test',
region: 'center',
plugins[filters],
viewConfig: {
forceFit: true
},
loadMask:true,
store: store,
columns: anExtension.MainColumns,
}, config);

anExtension.superclass.constructor.call(this, config);
},
});

Still got this "undefined"-Error.

Is it possible to define the filters at this point of code?

Thanks for any hint.
Mario

Stormseeker
26 May 2010, 11:31 AM
Oh man, I thought I was going crazy. Glad I did a forum search for this as I am running into this as well. I created this override as a temporary fix and it seems to be working...



Ext.override(Ext.ux.grid.GridFilters, {

addFilters : function (filters) {
if (filters) {
var i, len, filter, cm = false, dI;
if (filters instanceof Ext.grid.ColumnModel) {
filters = filters.config;
cm = true;
}
for (i = 0, len = filters.length; i < len; i++) {
filter = false;
if (cm) {
dI = filters[i].dataIndex;
filter = filters[i].filter || filters[i].filterable;
if (filter){
filter = (filter === true) ? {} : filter;
Ext.apply(filter, {dataIndex:dI});
// filter type is specified in order of preference:
// filter type specified in config
// type specified in store's field's type config
filter.type = filter.type || this.store.fields.get(dI).type.type;
}
}
else {
filter = filters[i];
}
// if filter config found add filter for the column
if (filter) {
this.addFilter(filter);
}
}
}
}

});


Anyway this can get fixed for 3.2.2?

Thanks,
Tim