PDA

View Full Version : getValue is not method



niveditaWebbee
8 Feb 2012, 4:27 AM
Solved:I am creating an application in which I am using radiofield group name paid

but in this line
var updatePaymentStatus = Ext.getCmp('paid').getValue();

it is throwing error that "Cannot call method 'getValue' of undefined"


Dont know why this error ??
Plz help or tell me how to get the checked value (:|

Sameer Khan
8 Feb 2012, 5:21 AM
HI, i think for the radio field group you have to maintain unique id's for all the elements, but name should same for the entire radio group...
If u try to get value on name of radio group, we will get this problem..

Just try this code & under stand this code and apply on ur example...U will get Idea..

Sample Code:
-----------------
{
xtype: 'container',
layout:'hbox',
defaults:{xtype : 'radiofield', labelAlign : 'right',labelWidth : '60%', flex:1},
items:[{
label: '1-Early',
name: 'm0110_epTiming',
id :'m0',
value:'1'
},{
label: '2-Later',
name: 'm0110_epTiming',
id :'m1',
value:'2'
},{
label: 'UK',
name: 'm0110_epTiming',
id : :m2',
value:'-2'
},{
label: 'NA',
name: 'm0110_epTiming',
id : 'm3',
value:'-1'
}]
},

Now u call like this:

FormPanelObject.getValues().m0110_epTiming --> you will get Value

(Or)
Ext.getCmp('m0').getValue();
Ext.getCmp('m1').getValue();
Ext.getCmp('m2').getValue();
Ext.getCmp('m2').getValue();
// Here individually u need to call on id of radio field items, then only u will get radio field item values...

Let me know... thanks .,..

niveditaWebbee
8 Feb 2012, 8:25 PM
Thanx Sameer for helping me out but name of radiofields are already same:

{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', label: 'Delivered', checked:true,value:0},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', label: 'Paid',value:1},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', label: 'Not Paid',value:2},
{xtype: 'spacer' }

I want value of checked field and it is not the part of any form.........

Sameer Khan
8 Feb 2012, 9:37 PM
Hi, Just send me your form code code..I will have a look at this. And i will let you know how u r doing ?

If radio field is the element for the form then you can call "yourformname.getValues().paid"...it will give the radio field value what ever you select ...

niveditaWebbee
8 Feb 2012, 10:30 PM
var changePayment = function(oid) {

if (!Ext.is.Phone) { //Nivedita Jain
var oID=oid;

var Payment = new Ext.form.FormPanel({
floating: true,

url: server_path + '?action=paymentchange&oID='+oid,
scroll: 'vertical',
width: 440,
height: 400,
standardSubmit: false,
centered: true,
id:'changePayment',
autoRender: true,
modal: false,
hideOnMaskTap: false,
layout: 'fit',

dockedItems: [
{ xtype: 'toolbar', title: 'Payment' },
{ items: [
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'delivered',label: 'Delivered', checked:true,value:0},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'pay',label: 'Paid',value:1},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'notPay', label: 'Not Paid',value:2},
{xtype: 'spacer' }
]
},

{ xtype: 'toolbar', docked:'bottom',items:[
{text: 'Save',name:'save',handler: function() {
// alert("hello");
var updatePaymentStatus = Ext.getCmp('paid').getValue();

alert(updatePaymentStatus+" value");
Ext.Ajax.request({
url: server_path + '?action=updatePayment',
method: 'POST',
params: {
payment:updatePaymentStatus,
order:oID
},
success: function (res, req) {
Ext.Msg.alert("Mpole", "Payment Updated");
},
failure: function (res, req) {
Ext.Msg.alert("Mpole", "Some Problem has Occured");
}
});
Payment.hide();
}},

{text: 'Cancel',name:'cancel',handler: function() {
Payment.reset();
Payment.hide();
}
}
]
}

],cls: 'modelWindow',
store: paymentchangeStore
})
//alert(oid);
paymentchangeStore.load({params: {oID: oid}});
Payment.show();
}
}

niveditaWebbee
8 Feb 2012, 10:31 PM
var changePayment = function(oid) {

if (!Ext.is.Phone) { //Nivedita Jain
var oID=oid;

var Payment = new Ext.form.FormPanel({
floating: true,

url: server_path + '?action=paymentchange&oID='+oid,
scroll: 'vertical',
width: 440,
height: 400,
standardSubmit: false,
centered: true,
id:'changePayment',
autoRender: true,
modal: false,
hideOnMaskTap: false,
layout: 'fit',

dockedItems: [
{ xtype: 'toolbar', title: 'Payment' },
{ items: [
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'delivered',label: 'Delivered', checked:true,value:0},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'pay',label: 'Paid',value:1},
{xtype: 'spacer' },
{xtype: 'radiofield',name: 'paid', id:'notPay', label: 'Not Paid',value:2},
{xtype: 'spacer' }
]
},

{ xtype: 'toolbar', docked:'bottom',items:[
{text: 'Save',name:'save',handler: function() {
// alert("hello");
var updatePaymentStatus = Ext.getCmp('paid').getValue();

alert(updatePaymentStatus+" value");
Ext.Ajax.request({
url: server_path + '?action=updatePayment',
method: 'POST',
params: {
payment:updatePaymentStatus,
order:oID
},
success: function (res, req) {
Ext.Msg.alert("Mpole", "Payment Updated");
},
failure: function (res, req) {
Ext.Msg.alert("Mpole", "Some Problem has Occured");
}
});
Payment.hide();
}},

{text: 'Cancel',name:'cancel',handler: function() {
Payment.reset();
Payment.hide();
}
}
]
}

],cls: 'modelWindow',
store: paymentchangeStore
})
//alert(oid);
paymentchangeStore.load({params: {oID: oid}});
Payment.show();
}
}

Sameer Khan
8 Feb 2012, 11:19 PM
Here, your code is very clear, why don't you use "this.getValues().paid" , it will give u the radio field value..It's very simple.

One more thing is Ext.Ajax.request() won't work for cross domain communication...so You can ues JSONP request....If u use Ext.AJax.request() it always gives you status code -0...