Hi,
And here is a sample, where I am loading my store and using the variable.
Any suggestions? It works fine in development...
Help, problems with variables!
I have just completed my first application, and the plan is to go live with it tomorrow, but I am stuck!
I am using a global variable in all my stores, but they dont load - so there must be something going on here.
This is my app.js
Code:
var isAdmin = false;var companyCode = "";
pageParameters = Ext.Object.fromQueryString(window.location.search.substring(1));
var values = Ext.Object.getValues(pageParameters);
companyCode = values[0];
if( Ext.Object.getSize(values)==2){
isAdmin = values[1];
}
var isOpen = false;
Ext.require(['Ext.TitleBar']);
Ext.application({
name: 'Hippocrates',
requires: [
'Ext.MessageBox'
],
views: [
'Main',
"Home",
"Horses",
"Newstat",
"Details",
"Order"
],
models:[
"User",
"NewStat"
],
stores:[
"User",
"NewStat"
],
controllers:["MyController"],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon@2x.png',
'144': 'resources/icons/Icon~ipad@2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
launch: function() {
//Hämta antalet ändringar på foderstat
Ext.Ajax.request({
url: 'Data/getCount.php?id=' + companyCode,
params: {
id: 1
},
success: function(response){
var text = response.responseText;
// Uppdatera knappen med antalet
Ext.getCmp('btn1').tab.setBadgeText(text);
}
});
//Hämta antalet liggandes ordrar
Ext.Ajax.request({
url: 'Data/getOrderCount.php?id=' + companyCode,
params: {
id: 1
},
success: function(response){
var text = response.responseText;
// Uppdatera knappen med antalet
Ext.getCmp('btn2').tab.setBadgeText(text);
}
});
//Hämta hem det senaste till hemskärmen
Ext.Ajax.request({
url: 'Data/viewHome.php?id=' + companyCode,
params: {
id: 1
},
success: function(response){
var text = response.responseText;
var eventDetailView = Ext.create('Hippocrates.view.Details');
Ext.getCmp("homePanel").setHtml(text);
// Destroy the #appLoadingIndicator element
if(isAdmin==false){
Ext.fly('appLoadingIndicator').destroy();
}
}
});
//Hämta arbetsorder
if(isAdmin=='true'){
//Hämta hem det senaste till hemskärmen
Ext.Ajax.request({
url: 'Data/getJob.php?id=' + companyCode,
params: {
id: 1
},
success: function(response){
var text = response.responseText;
var eventDetailView = Ext.create('Hippocrates.view.Details');
Ext.getCmp("orderPanel").setHtml(text);
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
}
});
}
// Initialize the main view
Ext.Viewport.add(Ext.create('Hippocrates.view.Main'));
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
And here is a sample, where I am loading my store and using the variable.
Code:
Ext.define('Hippocrates.store.NewStat', { extend: 'Ext.data.Store',
config: {
model: 'Hippocrates.model.NewStat',
autoLoad: true,
grouper: {
property: 'Stable',
direction:'ASC'
},
sorters: [{
property: 'Name',
direction: 'ASC'
}],
proxy: {
type: 'ajax',
url: 'Data/getAllNewStat.php?id=' + companyCode ,
reader: {
type: 'json'
}
},
listeners:{
load:function(s,result,success,op){
}
}
}
});
Any suggestions? It works fine in development...
Joakim
Help, problems with variables!
Aucun commentaire:
Enregistrer un commentaire