Monday, 15 April 2013

combobox - Cannot seem to populate combo box remotely in Extjs -



combobox - Cannot seem to populate combo box remotely in Extjs -

i've tried manor of things populate combo drop-down box. when typing, "apple", appears loading info but, nil ends in drop downwards box. firebug shows info has been loaded. so, going wrong? thanks.

ext.create('ext.form.field.combobox', { fieldlabel: 'basket', emptytext : 'type fruit name', querymode : 'remote', minchars : 3, fields : ['id', 'name'], store : { proxy: { type: 'jsonp', callbackkey: 'method', url: 'http://www.comparetrainfares.co.uk/train_scripts/data.php', reader: { root: 'items' }, } }, needlekey : 'query', labelkey : 'id', label : 'name', displayfield : 'name', width : 260, forceselection: true, renderto : query1, }); <?php header('access-control-allow-origin: *'); //header('content-type: application/json; charset=utf8'); //header('content-type: application/x-json'); // http://www.comparetrainfares.co.uk/train_scripts/data.php $output = array(); $output[] = array('id' => '1', 'name' => 'apple'); $output[] = array('id' => '2', 'name' => 'banana'); $output[] = array('id' => '3', 'name' => 'orange'); $output[] = array('id' => '4', 'name' => 'lemon'); $objects = array('items' => $output); echo json_encode($objects); ?>

you using jsonp proxy. not default ajax way of loading store. php script should receiving function name 'callback' parameter sent php script , returning info should in format this:

callback({"items":[{"id":"1","name":"apple"},{"id":"2","name":"banana"},{"id":"3","name":"orange"},{"id":"4","name":"lemon"}]})

and remember replace 'callback' name of whatever string beingness sent in callback parameter.

combobox extjs4.1

No comments:

Post a Comment