PDA

View Full Version : SearchField not showing the result in the grid



rich71
18 Jul 2010, 9:06 PM
Hi,

My question is related to the grid tutorial over here (http://www.sencha.com/learn/w/index.php?title=Tutorial:Grid_PHP_SQL_Part10)

I follow the tutorial precise and up till know, I came across one error related to the extjs version.

I am at step 10 and I want to show the result from the quicksearchfield.

The problem is that it doesn't show the result.
I know the query returns one row, because I stored it for testing in a php session variable.

That's why I think it is version related again.

Can someone take a look at the script and perhaps tell me what is possibly the problem?


Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
initComponent : function(){
Ext.app.SearchField.superclass.initComponent.call(this);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
this.onTrigger2Click();
}
}, this);
},

validationEvent:false,
validateOnBlur:false,
trigger1Class:'x-form-clear-trigger',
trigger2Class:'x-form-search-trigger',
hideTrigger1:true,
width:180,
hasSearch : false,
paramName : 'query',

onTrigger1Click : function(){
if(this.hasSearch){
this.el.dom.value = '';
var o = {start: 0};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = '';
this.store.reload({params:o});
this.triggers[0].hide();
this.hasSearch = false;
}
},

onTrigger2Click : function(){
var v = this.getRawValue();
if(v.length < 1){
this.onTrigger1Click();
return;
}
var o = {start: 0};
this.store.baseParams = this.store.baseParams || {};
this.store.baseParams[this.paramName] = v;
this.store.reload({params:o});
this.hasSearch = true;
this.triggers[0].show();
}
});

thanks, Richard

Condor
18 Jul 2010, 10:11 PM
If you are doing tutorial, now would be a good time to learn how to debug your javascript!

1. Attach load and exception listeners to the store and see which one fires. If it is the exception event, then check it's parameters.
2. Learn how to use a debugger (Firebug is still the best, but all modern browsers have their own debugger).

rich71
19 Jul 2010, 4:24 AM
Thanks,that's part of the reason I posted here.
But I try to learn it.

Console.log diddn't work for me and the xhr tab said source unknown or something along those lines.
I better google to find out what that means then. Setting up exceptions is problably in the documentation. I will check that out.


Anyway, about 10 seconds after I posted, I came up with the solution.
The script had a property {start:0}, so I made it into this {start:0,limit:50}
That was actually in the source off the tutorial, but I had to download the script and in that file the setting was omitted.

Anyway, this happens a lot to me, that I find the answer shortly after I post something.
I wish I could have stopped the posting, but no success.

thanks, Richard