PDA

View Full Version : Using value passed in parameters



marxan
11 Feb 2011, 1:11 AM
Hello,

Here's my question. I use a JS class to create a gridpanel.

So I call it like this:


var ProjectStatePanel = new Ext.Panel({
frame: true,
items: [{
layout: 'form',
items: [{
xtype: 'fullListProjectCurrentStatus',
id: 'fullListProjectCurrentStatus',
name: 'fullListProjectCurrentStatus',
phase: '#phase#',
directorate: '#directorate#',
unit : '#unit#',
user: '#user.currentusername#',
myproject: '#myproject#'
}]
}]
});

As you can see I pass some values to it so I can use it when I generate my store and this works fine.
The problem is that I want to use these values to pass it to an url( through the window.open in the code below) but when I do an alert of a value, the return is "undefined".


fullListProjectCurrentStatus = Ext.extend(Ext.grid.GridPanel, {
border:false,
initComponent:function() {
var store = new Ext.data.JsonStore({
totalProperty: 'DATASET',
root: 'ROWS',
url: '../components/JSONProject.cfc',
baseParams:
{
method: 'GetFullListProject',
returnFormat: 'JSON',
phase: this.phase,
directorate: this.directorate,
unit: this.unit,
user: this.user,
myproject: this.myproject
},
reader: ProjectReader,
fields:[
'FP',
'Call',
'Dir',
'Unit',
'Project',
'Acronym',
'PO',
'CurrentStep',
'Period',
'GrossElapseTime',
'ClockElapseTime',
'ClockState',
'Phase'
]
});

var config = {
store: store,
autoHeight: true,
title: 'Project Current Status',
loadMask: true,
tbar:[ '->',
{
text: 'Export to Excel',
iconCls: 'excelButton',
handler: function(){

}
}
],
tools: [{
id:'excelButton',
qtip: 'Display all results in a page',
// hidden:true,
handler: function(event, toolEl, panel){
alert(this.phase);
window.open('../export/ProjectCurrentStatusToExcel.cfm?phase='+this.phase+'&directorate='+this.directorate+'&unit='+this.unit+'&myproject='+this.myproject+'&user='+this.user);
}
}],


My question is merely how to use these values in my window.open?

Thanks in advance for any explanation.

steffenk
11 Feb 2011, 1:35 AM
use store.load listener to read the params and use them as class vars.

tobiu
11 Feb 2011, 1:36 AM
you could extend the window, give it some new params and write a setter-method for your variables.
then go like:

window.setMyParams(...);
window.open();


best regards
tobiu

marxan
11 Feb 2011, 2:26 AM
Hi steffenk,

I don't see what you mean by using the store.load listener to read the params...

If I do a store.load() it returns me true. How can I get the params linked to it?

Thanks

steffenk
11 Feb 2011, 4:49 AM
add this to your store:

listeners: {
load: function(store, records, options) {
console.log('LOAD', options);
},
scope: this
}

marxan
11 Feb 2011, 5:33 AM
Thanks,

I can see now in firebug that I have a load Params but still don't know how to get it. I can't any method such as getParams...

Sorry for my basics question, I've never done such a thing.

marxan
11 Feb 2011, 7:39 AM
Here's the complete solution. To retrieve the params: option.params.nameOfTheParam.


var store = new Ext.data.JsonStore({
totalProperty: 'DATASET',
root: 'ROWS',
url: '../components/JSONProject.cfc',
baseParams:
{
method: 'GetFullListProject',
returnFormat: 'JSON',
phase: this.phase,
directorate: this.directorate,
unit: this.unit,
user: this.user,
myproject: this.myproject
},
listeners: {
load: function(store, records, options) {
window.open('../export/ProjectCurrentStatusToExcel.cfm?phase='+options.params.phase+'&directorate='+options.params.directorate+'&unit='+options.params.unit+'&myproject='+options.params.myproject+'&user='+options.params.user);

//console.log('LOAD', options);
},
scope: this
},
reader: ProjectReader,
fields:[
'FP',
'Call',
'Dir',
'Unit',
'Project',
'Acronym',
'PO',
'CurrentStep',
'Period',
'GrossElapseTime',
'ClockElapseTime',
'ClockState',
'Phase'
]
});

var config = {
store: store,
autoHeight: true,
title: 'Project Current Status',
loadMask: true,
tbar:[ '->',
{
text: 'Export to Excel',
iconCls: 'excelButton',
handler: function(){

}
}
],
tools: [{
id:'excelButton',
qtip: 'Display all results in a page',
// hidden:true,
handler: function(event, toolEl, panel){
//CALL THE METHOD CREATED IN THE STORE
store.load();
}
}],