PDA

View Full Version : search able combobox



mnask79
11 Mar 2010, 1:43 AM
hi all ,

am working on search-able combobox

but i'm getting the following error "invalid label"

the source is



Ext.onReady(function(){

var ds = new Ext.data.Store({
proxy: new Ext.data.ScriptTagProxy({
url: 'districtProxy.php'
}),
reader: new Ext.data.JsonReader({
root: 'district',
totalProperty: 'totalCount'
}, [
{name: 'DIST_E'}
])
});

// Custom rendering Template
var resultTpl = new Ext.XTemplate(
'<tpl for="."><div class="search-item">',
'<h3>{DIST_E}</h3>',
'</div></tpl>'
);

var search = new Ext.form.ComboBox({
store: ds,
displayField:'DIST_E',
typeAhead: false,
loadingText: 'Searching...',
width: 570,
pageSize:10,
hideTrigger:true,
tpl: resultTpl,
applyTo: 'search',
itemSelector: 'div.search-item',
onSelect: function(record){ // override default onSelect to do redirect
// window.location =
// String.format('http://extjs.com/forum/showthread.php?t={0}&p={1}', record.data.topicId, record.id);
}
});
});

server side





$districts = array();
$districtRec = array();

$sql = "SELECT * FROM district WHERE DIST_E LIKE '%".$_GET['query']."%'";
$result = mcq($sql,$db);
while($rec = mysql_fetch_array($result)){
$districtRec['DIST_E'] = $rec['DIST_E'] ;

$districts[] = $districtRec ;
}

$JsonArr = array ('totalCount'=>count($districts),'district'=>$districts);
echo json_encode($JsonArr) ;
exit();


where is the problem please ?

mnask79
11 Mar 2010, 2:45 AM
anybody can help ?

fay
11 Mar 2010, 3:03 AM
You waited a full hour ;)

Why are you using ScriptTagProxy? See the docs (http://www.extjs.com/deploy/dev/docs/?class=Ext.data.ScriptTagProxy) for what it expects back from your server:


The content passed back from a server resource requested by a ScriptTagProxy must be executable JavaScript source code because it is used as the source inside a <script> tag.

Try it with HttpProxy. Also, add load and exception handlers to your store to ensure it it loading your data (or if not, why!)