PDA

View Full Version : Open a new Extjs Desktop window on click of a grid item



jepedregosa
2 Jan 2013, 1:21 AM
I am new to ExtJS and I am exploring on the extjs desktop app. I created a grid wherein when I click a row/item on the grid, It will open a desktop window form with the data from the selected item on the grid. The problem is I cannot open a new Desktop window after I click on the item. Here is my code



listeners: { itemdblclick: function(dv, record, item, index, e){
console.log("test"); //check if grid can listen on double click
new MyDesktop.Form1().;
}
},


and the code for the Form1 :



Ext.define('MyDesktop.Form1', {
extend: 'Ext.ux.desktop.Module',


requires: [
'Ext.data.ArrayStore',
'Ext.util.Format',
'Ext.grid.Panel',
'Ext.grid.RowNumberer'
],


id:'form-win',


init : function(){
// this.launcher = {
// text: 'Form Window',
// iconCls:'icon-grid'
// };
},
createWindow : function(){
var desktop = this.app.getDesktop();
var win = desktop.getWindow('form-win');
var required = '<span style="color:red;font-weight:bold" data-qtip="Required">*</span>';
var operation;
if (!win) {
win = desktop.createWindow({
id: 'Form',
title:'Form1',
width:600,
height:400,
// iconCls: '',
animCollapse:false
});
win.add({
xtype: 'form',
id: 'formpanel',
frame: true,
border: false,
layout: 'anchor',
fieldDefaults: {
msgTarget: 'side',
labelWidth: 75
},
defaultType: 'textfield',
items: [{
fieldLabel: 'Branch ID',
afterLabelTextTpl: required,
name: 'id',
allowBlank: false
},
{
fieldLabel: 'Branch Description',
afterLabelTextTpl: required,
name: 'desc',
allowBlank: false
}
],
tbar:[
'-',
{
text:'Save',
tooltip:'Save Data',
handler: function(){
var form = Ext.getCmp('formpanel').getForm();
if(form.isValid()){
form.submit({
waitMsg:'Loading...',
url: './BranchServlet',
params: {'operation': operation},
success: function(form,action) {
Ext.Msg.alert('Success', 'Saved!');
win.doClose();
},
failure: function(form,action){
Ext.Msg.alert('Error',action.result.data.msg);
}
});
}
}
}, '-', {
text:'Cancel',
tooltip:'Cancel all changes',
handler: function() {
win.doClose();
}
}, '-'
]
});
}else{

}
return win;
},
enableField : function(field){
field.disabled = false;
return true;
}
});


Thank you in advance.

mitchellsimoens
4 Jan 2013, 8:10 AM
First issue I see is this line probably gives you an error:


new MyDesktop.Form1().;