I'm trying to load json data to my combo box using jsonStore.
The store is using PHP for retrieving the data from the sever.
I can see that the server is handling the PHP request and response with proper json data, but somehow the combobox stays empty.
Relevant code:
The store and the ComboBox - the ComboBox is inside FormPanel:
var groupsStore= new Ext.data.JsonStore({url:'login.php?action=getGroups',
root: 'entities',
fields: [{name:'groupName', mapping:'groupName'}]
});
LoginWin = function(cfg) {
this.form = new Ext.form.FormPanel({
labelWidth:60, baseCls:'x-plain', autoHeight:true, style:'padding:5px',
items:[
{xtype:'combo', name:'groups', fieldLabel:'Group', store:groupsStore,
displayField:'groupName', valueField:'groupName', emptyText:'Pick group...', mode:'remote', anchor:'95%', allowBlank:false, enableKeyEvents:true, triggerAction:'all', forceSelection:true
, listeners:{keypress:{scope:this, fn:function(fld,e){ if(e.getKey()==e.ENTER) doLogin();}}
}}
]
});
The json data that returned from the server:
{"entities":[{"@type":"webGroup","groupId":"1","groupName":"TEST","groupUsers":
[{"groupUserId":"2","groupUserName":"FOO","password":"123456"},
{"groupUserId":"1","groupUserName":"FOO","password":"654321"}],"system":"BLA"},
{"@type":"webGroup","groupId":"2","groupName":"TESTOS","system":"BLA"}]
,"success":"true"}
The PHP code:
function getGroups(){
error_log("API_host: ".$API_host, 0);
global $API_host;
error_log("API_host: ".$API_host, 0);
$url="$API_host/GroupUser/groups";
error_log("url: ".$url, 0);
$jsonData = curl_request($url);
if (!$jsonData) die("{success:false, message:'Connection Error'}");
echo $jsonData;
}
Maybe the data returned from the PHP formatted other than JSON? How can i know it? I'm not sure of anything.
Can't understand why it's not working.
Any ideas anyone?
Thanks so much.