Hi,
I just created my very 1st Sencha webapp. Since I am new to Sencha and the documentation is not that perfect I was forced to make some guesses to make things work the way I wanted. Although everything is working I am pretty shore that what I had done is not the "Sencha Way".
So, here is my code. I would love to know what would be the right Sencha way to make it happen.
The part I am not shore of is a response to a itemtap event, so my controller is :
Code:
Ext.define('iStatView.controller.Main', {
extend: 'Ext.app.Controller',
config: {
refs: {
UsersList: 'UsersList'
},
control: {
'UsersList list': {
itemtap: 'ShowInfo'
}
}
},
ShowInfo: function(List, Index, Element, Record){
this.getUsersList().push({
xtype: 'panel',
id: "StatPanel",
title: 'Stats for ' + Record.get('UserID'),
scrollable: true,
stylehtmlcontent: true
});
Ext.data.JsonP.request({
url: '<a php code which return json data>',
callbackKey: 'callback',
params:{
UserID: Record.get('UserID')
},
success: function(result, request) {
var StatPanel = Ext.getCmp("StatPanel");
for (var SectionIndex in result){
var StatFieldSet = StatPanel.insert(100, {xtype: 'fieldset', title: SectionIndex, id: SectionIndex});
if (result[SectionIndex] == "No Data"){
StatFieldSet.insert(100, {xtype: 'textfield', label: '', value: 'No Data'});
}
else {
for (var ParamIndex in result[SectionIndex]){
StatFieldSet.insert(100, {xtype: 'textfield', label: ParamIndex, value: result[SectionIndex][ParamIndex]});
}
}
}
}
});
}
});
The JSON data I get back from the php is a bit longer then what you see below what you get the idea ;-):
Code:
{
"SystemData": {
"WidgetVersion": "05.03.00",
"Platform": "windows",
"UserID": "E080760",
"DateTime": "20120610180003",
"StartTime": "20120609015351",
"UpTime": "2586"
},
"LastUpdate": {
"UTCSync": "20120610000003",
"Version": "20120610000004",
"Statistics": "20120610000001",
"Weather": "20120610170004",
"SigMet": "20120610170004",
"NATTracks": "20120610170005",
"EFRAS": "20120610000007",
"Songkick": "20120610000011",
"Notam": "20120610170008",
"MyRotemFlights": "20120609112530"
}
}
Thanks for any ideas, comments, enlightenments .....
Erez