PDA

View Full Version : StringFilter not working like example



incanus
27 Jan 2011, 4:17 AM
Hi all of you,
i'm trying to get a StringFilter working, and it really works, but not as it's expected.
I've copied the code just as in the example:

http://dev.sencha.com/deploy/dev/examples/grid-filtering/grid-filter-local.html

And the filter is shown deactivated until reconfigure is called. All ok until here.

The default behaviour i see in the example is the next:

-When the textfield is empty, the checkbox Filters is unchecked, and the filter deactivated.
-When i stat typing in the textfield, the checkbock gets checked, and the filter gets activated.
-Modifying the textfield, the field is applyied any time i get the value changed.
-If i delete all the content in the textfield, the checkbox gets unchecked.

But, in my page, non of this behavious is working. I only get the filter working manually checking the checkbox, and while i'm modifying the value of the textfield, the filter doesn't aply 'on the fly'.

Anyone has experimented this?
Thanx in advance,
Regards

PD: Neither is possible to select the content of the textfield.

incanus
28 Jan 2011, 12:27 AM
Hi again,

Debugging it, i've seen that a error is fired exactly in the time i edit the content of the textfield (every change i do). The error is this:


this.inputItem.getValue() is undefined
.../resources/ext-3.3.1/ux/StringFilter.js Line: 87
I searched the line in StringFilter.js (my copy is in that root), and it's coming from:



(........)

Ext.ux.grid.filter.StringFilter = Ext.extend(Ext.ux.grid.filter.Filter, {
(........)
},

/**
* @private
* Template method that is to return <tt>true</tt> if the filter
* has enough configuration information to be activated.
* @return {Boolean}
*/
isActivatable : function () {
return this.inputItem.getValue().length > 0;
},

/**
(........)



And since it is a GridFilters extension code, i don't know what is caunsing it.

I would appreciate any help.

incanus
28 Jan 2011, 1:39 AM
I found a workaround, but it's not a "clean" solution, and i can't still made a selection on the textfield, but it works (or it could be said to work). What i've done is:

First, I've overriden the function isActivatable (the one wich threw the error because this.inputItem.getValue() was undefined):


<script type = "text/javascript">

Ext.override(Ext.ux.grid.filter.StringFilter,{
isActivatable : function () {
return true; //this.inputItem.startValue.length > 0;
}
});

</script>
and inside the createColModel function, i have initialized the filter as active:



filter:{type: 'string',active:true}
If anyoune could have a better solution, I'd really appreciate that.

Regards

Nendrel
19 Dec 2011, 9:15 AM
Hi there,
Thanks a lot for the workaround. I had the same bug.
After i fixed that, i found this other bug:
this.getValue() is undefined

I fixed it with this other workaround:


Ext.override(Ext.ux.grid.filter.StringFilter,{
isActivatable: function() {
return true; //this.inputItem.startValue.length > 0;
},
validateRecord: function (record) {
var val = record.get(this.dataIndex);
if (typeof val != 'string') {
return (this.getValue().length === 0);
}
if (typeof this.getValue() != 'undefined') {
return val.toLowerCase().indexOf(this.getValue().toLowerCase()) > -1;
} else {
return true;
}
}
});