PDA

View Full Version : i need help with applyif()



leerooy
11-07-2013, 11:33 AM
I have a playqueue domain class which should allow the user with required permission to be able to click on the music icon and a pop-up of the details of the song should then appear, while the song is in a playqueue.
My question is what could possibly prevent the pop-up window to show, as when I click on the music icon in the playqueue nothing happens?
I managed to pin point where the problem might be, even though I don't understand why there is a problem there. In the function below, line 15 is where it seems to be having problems.

1. this.buildForm = function(){
2. var numCols = 2;
3. this.propertyForm = this.getColumnPropertyPanel(numCols);
4.
5. var pCfg = {
6. title: messages.JS.playqueue.songTitle.songTitle(),
7. labelWidth: 105,
8. header: false,
9. border: false,
10. autoHeight: true,
11. autoScroll: true,
12. items: [this.propertyForm, this.buildRemarksForm()]
13. }
14.
15. Ext.applyIf(pCfg, cfg)
16. this.panel = new Ext.Panel(pCfg);
17. return this.panel
18. }

this.getColumnPropertyPanel = function(numCols){
var cols = [], dataLen = this.data.length, viewLen = this.view.length, numRows = Math.ceil( Math.min(dataLen, viewLen) / numCols );
for(var i=0; i<numCols; ++i){
var data = [], view = [];
for(var j=0; j<numRows && j+i*numRows<dataLen; ++j){
var dataIdx = j+i*numRows;
if(this.view[dataIdx] && this.data[dataIdx] && this.view[dataIdx].id == this.data[dataIdx].id){
view.push( this.view[dataIdx] );
data.push( this.data[dataIdx] );
}
}
cols[i] = new Ext.mtg.PropertyForm({
columnWidth: 1/numCols,
labelWidth: labelWidth,
anchor: '98%',
itemsAnchor: '98%',
border: false,
view: view,
data: data,
readOnly: readOnly
});
}
var panel = new Ext.Panel({
layout: 'column',
border: false,
items: cols
});
Ext.apply(panel, {
getValues: function(){
var ret = {}
Ext.each(cols, function(c){
Ext.applyIf(ret, c.getValues());
})
return ret
},

getRawValues: function(){
var ret = {}
Ext.each(cols, function(c){
Ext.applyIf(ret, c.getRawValues());
})
return ret
},

isValid: function(){
var valid = true;
Ext.each(cols, function(c){
valid = valid && c.getForm().isValid();
});
return valid;
}
});
return panel;
}

this.buildRemarksForm = function(){
this.remarksForm = new Ext.form.FormPanel({
layout:'column',
border: false,
labelWidth: labelWidth,
anchor: "100%",
items:[{
columnWidth: 0.5,
layout: 'form',
border: false,
items: [{
xtype:'textarea',
fieldLabel: messages.JS.playqueue.songTitle.remarks1(),
name: 'remarks1',
anchor: '98%',
value: this.remarks1,
plugins: (readOnly?[new Ext.ux.form.FieldViewMode()]:[])
}]
},{
columnWidth: 0.5,
layout: 'form',
border: false,
items: [{
xtype:'textarea',
fieldLabel: messages.JS.playqueue.songTitle.remarks2(),
name: 'remarks2',
anchor: '98%',
value: this.remarks2,
plugins: (readOnly?[new Ext.ux.form.FieldViewMode()]:[])
}]
}]
});
return this.remarksForm;
}