PDA

View Full Version : ComboBox remote trigger not working



jelly
15 Aug 2008, 1:42 AM
Hello,

I am trying to get a ComboBox trigger (button) to perform the same search that onchange does on a remote HttpProxy but when I set triggerAction to 'all' it doesn't do the remote search and find any results, also after I click it once it doesn't even start the search.



Ext.onReady(function(){
var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy ({
url: 'php script being called.php'
}),
reader: new Ext.data.JsonReader({
root: 'topics',
totalProperty: 'totalCount',
id: 'id'
}, [
{name: 'id', mapping: 'id'}
]),

baseParams: {limit:20, forumId: 4}
});

// Custom rendering Template for the View
var resultTpl = new Ext.XTemplate(
'<tpl for=".">',
'<div class="search-item">',
'<p class="content" style="padding:10px">{id}</p>',
'</div></tpl>'
);

var search = new Ext.form.ComboBox({
store: ds,
displayField:'title',
typeAhead: false,
loadingText: 'Searching...',
pageSize:10,
emptyText: 'Search',
width: 100,
listWidth: 500,
pageSize:10,
minChars: 2,
hideTrigger:false,
triggerClass : 'x-form-search-trigger',
tpl: resultTpl,
applyTo: 'search',
itemSelector: 'div.search-item',
triggerAction: 'all',
lazyInit: false,

onSelect: function(record){
//$('hiddenField').value = record.id
this.collapse();
}
});
});
Could this be because the triggerAction only looks locally and cannot do a remote call?

Thanks in advance and help is always very appreciated...

This is a great product keep up the great work...

jelly
18 Aug 2008, 2:01 AM
A similar issue seems to have been addressed in this post but it hasn't been resolved.

http://extjs.com/forum/showthread.php?t=42063&highlight=ComboBox+remote+trigger

jelly
18 Aug 2008, 4:00 AM
I have fixed this problem by using the onTriggerClick function and then putting the focus on the field and expanding it. So this now does a search on what ever is in the search input field when the trigger button is pressed.



//triggerAction: 'all',
onTriggerClick: function() {
this.store.load({
params: {query:document.form1.search.value,start:0}
});
this.focus();
this.expand();
},
This works well but when I then page through the results the string the search is performed on is not carried across. I will keep working on this but I hope my investigation helps somebody else.