PDA

View Full Version : Problem With Show / Hide formPanel on window



andylah
21 Dec 2011, 12:42 AM
can someone help me with this problem? how can i fix it

i have a pop up window that will show when user click tbar on grid. first time user click tbar add on grid window show normal (First.jpg) but when user click it again it will recreated textfield that has already in the formField (second.jpg).

this is the code :


package("imgv2.salesorder");



imgv2.salesorder.salesorderdetail = function(salesOrderGridStore,txtg_total,txtgrand_total,txt_sub_total,salesorder_code) {

var salesorderdetailReader = new Ext.data.JsonReader({

id:'salesorderdetailReader',

root:'results'

},[{name:'part_desc'},{name:'part_price'},{name:'measure_code'}])



var partStore = new Ext.data.Store({

proxy:new Ext.data.HttpProxy({

url:'php/salesorder.php',

method:'post'

}),

baseParams:{task:'loadComboPart'},

reader:new Ext.data.JsonReader({

id:'partReader',

root:'results'

},[{name:'part_code'},{name:'part_codename'}]),

sortInfo:{field:'part_code',direction:'ASC'}

})



var measureStore = new Ext.data.Store({

proxy:new Ext.data.HttpProxy({

url:'php/salesorder.php',

method:'post'

}),

baseParams:{task:'loadComboMeasure'},

reader: new Ext.data.JsonReader({

id:'measureReader',

root:'results'

},[{name:'rowid'},{name:'measure_code'}]),

sortInfo:{field :'measure_code',direction:'ASC'}

})



var cmbcode = new Ext.form.ComboBox({

//id:'part_codeid',

fieldLabel: 'Product Code ',

name:'part_code',

valueField:'part_code',

displayField:'part_codename',

mode:'local',

store:partStore,

emptyText:'Please select ...',

triggerAction:'all',

allowBlank:false,

selectOnFocus:true,

editable:false,

width:150,

listeners:{

select:function(){

salesorderdetailForm.load({waitMsg:'Loading',url:'php/salesorder.php',params:{task:'loadProductDetail',id:this.value}})

},

focus:function(){

partStore.load()

}

}

})



var cmbmeas = new Ext.form.ComboBox({

name:'measure_code',

fieldLabel: 'Part Measure ',

mode:'remote',

typeAhead: false,

valueField:'rowid',

allowBlank:false,

emptyText:'Please select ...',

displayField:'measure_code',

store:measureStore,

triggerAction:'all',

selectOnFocus:true,

editable:false,

width:150

})



var cmbpacking = new Ext.form.ComboBox({

name:'salesorder_packing',

fieldLabel: 'Packing ',

mode:'local',

allowBlank:false,

typeAhead: false,

valueField:'salesorder_packingid',

emptyText:'Please select ...',

displayField:'salesorder_packing',

triggerAction:'all',

selectOnFocus:true,

width:150,

editable:false,

store:new Ext.data.SimpleStore({

fields:['salesorder_packingid','salesorder_packing'],

data:[

['p-0','1 pcs IB / 12 pcs OB'],

['p-1','1 pcs IB / 24 pcs OB'],

['p-2','2 pcs IB / 72 pcs OB'],

['p-3','3 pcs IB / 12 pcs OB'],

['p-4','3 pcs IB / 24 pcs OB'],

['p-5','3 pcs IB / 36 pcs OB'],

['p-6','6 pcs IB / 36 pcs OB'],

['p-7','6 pcs IB / 48 pcs OB'],

['p-8','6 pcs IB / 72 pcs OB'],

['p-9','6 pcs IB / 144 pcs OB'],

['p-10','12 pcs IB / 36 pcs OB'],

['p-11','12 pcs IB / 48 pcs OB'],

['p-12','12 pcs IB / 72 pcs OB'],

['p-13','12 pcs IB / 144 pcs OB'],

['p-14','24 pcs IB / 36 pcs OB'],

['p-15','24 pcs IB / 48 pcs OB'],

['p-16','24 pcs IB / 72 pcs OB'],

['p-17','24 pcs IB / 144 pcs OB']

]

})

})



var cmbcontainer = new Ext.form.ComboBox({

name:'salesorder_container',

fieldLabel: 'Container ',

mode:'local',

typeAhead: false,

allowBlank:false,

valueField:'salesorder_containerid',

emptyText:'Please select ...',

displayField:'salesorder_container',

triggerAction:'all',

selectOnFocus:true,

editable:false,

width:150,

store:new Ext.data.SimpleStore({

fields:['salesorder_containerid','salesorder_container'],

data:[

['1','1 x 20 FT'],

['2','2 x 20 FT'],

['3','3 x 20 FT'],

['4','4 x 20 FT'],

['5','5 x 20 FT'],

['6','1 x 40 FT'],

['7','2 x 40 FT'],

['8','3 x 40 FT'],

['9','4 x 40 FT'],

['10','5 x 40 FT'],

['11','1 x 40 HQ'],

['12','2 x 40 HQ'],

['13','3 x 40 HQ'],

['14','4 x 40 HQ'],

['15','5 x 40 HQ']

]

})

})



var txtdesc = new Ext.form.TextField({name:'part_desc',width:250,disabled:true,fieldLabel:'Description '})



var txtprice = new Ext.form.TextField({name:'part_price',id:'part_price_id',width:75,allowBlank:false,fieldLabel:'Price '})



var txtqty = new Ext.form.NumberField({name:'salesorder_qty',id:'salesorder_qty_id',width:75,allowBlank:false,fieldLabel:'Quantity ',value:'0'})



var txtdisc = new Ext.form.NumberField({name:'salesorder_disc',id:'salesorder_disc_id',width:75,allowDecimals:true,fieldLabel:'Disc % ',value:'0'})



var txttax = new Ext.form.NumberField({name:'salesorder_tax',id:'salesorder_tax_id',width :75,allowDecimals:true,fieldLabel : 'Tax % ',value:'0'})



var salesorderdetailForm = new Ext.FormPanel({

id:'salesorderdetailForm',

bodyStyle:'padding:3px',

baseCls: 'x-plain',

autoWidth:true,

reader:salesorderdetailReader,

autoHeight:true,

labelWidth: 100,

url:'php/salesorder.php',

items:[

cmbcode,

txtdesc,

cmbpacking,

cmbcontainer,

txtprice,

txtqty,

cmbmeas,

txtdisc,

txttax

]

})



var detailorderwindow = new Ext.Window({

width:400,

autoHeight:true,

title:'Add Product To Shopping Cart',

bodyStyle:'padding:5px 3px 0',

layout : 'fit',

closable:false,

plain:true,

buttonAlign:'center',

id:'detailorderwindow',

items:salesorderdetailForm,

buttons:[

{text:'Save',iconCls:'icon-db-save',handler:function(){

if(salesorderdetailForm.getForm().isValid())

{

salesorderdetailForm.getForm().submit({

params:{task:'ProcessDetail',phase:'saveDetail'},

waitMsg:'Saving Data ...',

waitTitle:'Process',

failure:function(salesorderdetailForm,action){

Ext.MessageBox.alert('Error',action.result.errorInfo)

},

success:function(){

detailorderwindow.hide()

salesOrderGridStore.load({waitMsg:'Loading',params:{task:'ProcessDetail',phase:'LoadDetailGrid',salesorder_code:salesorder_code}})

if(Ext.get('buy_price_id').dom.value=="")

{



var gtotal_data = new Ext.data.Store({

proxy: new Ext.data.HttpProxy({

url:'php/salesorder.php?task=ProcessDetail&phase=LoadTotal'

}),

reader:new Ext.data.JsonReader({root:'results'},['gtotal','gtotal_all'])

})



gtotal_data.on('load',function(){

txtg_total.setValue(gtotal_data.getAt(0).get('gtotal'))

txtgrand_total.setValue(gtotal_data.getAt(0).get('gtotal_all'))

txt_sub_total.setValue(gtotal_data.getAt(0).get('gtotal'))

})



gtotal_data.load();



}else{

var a = Ext.get('currency_codeid').dom.value;

var b = salesorder_code;

var gtotal_data = new Ext.data.Store({

proxy: new Ext.data.HttpProxy({

url:'php/salesorder.php?task=ProcessDetail&phase=LoadTotalAll&id='+a+'&salesorder_code='+b

}),

reader:new Ext.data.JsonReader({root:'results'},['gtotal','gtotal_all','subtotal'])

})



gtotal_data.on('load',function(){

txtg_total.setValue(gtotal_data.getAt(0).get('gtotal_all'))

txtgrand_total.setValue(gtotal_data.getAt(0).get('gtotal'))

txt_sub_total.setValue(gtotal_data.getAt(0).get('subtotal'))

})



gtotal_data.load();



}

}

})

}else{

Ext.MessageBox.alert('Warning','Please fix the error !!!')

}

}},

{text:'Reset',iconCls:'icon-db-refresh',handler:function(){

salesorderdetailForm.getForm().reset()

}},

{text:'Cancel',iconCls:'',handler:function(){

detailorderwindow.hide()

}}

]

})



detailorderwindow.show();

}


thanks before

30202
30203

mitchellsimoens
21 Dec 2011, 7:25 AM
I have moved this to the Ext JS 3 Help forum. Please post in the appropriate forum

andylah
21 Dec 2011, 4:29 PM
Got the answer....

just remove id attribute at field, and the problem is solved.....