PDA

View Full Version : get value of radio button and checkbox



reena
28 Dec 2010, 1:09 AM
Hi,
How to get the value of radio button and checkbox.

Reena

Condor
28 Dec 2010, 1:24 AM
What do you expect the 'value' of a checkbox/radio to be?

true/false or undefined/inputValue?

reena
28 Dec 2010, 1:26 AM
input value

Condor
28 Dec 2010, 1:32 AM
var value = (checkbox.getValue() ? (checkbox.el ? checkbox.el.dom.value : checkbox.inputValue) : undefined);

reena
28 Dec 2010, 1:38 AM
and how to get input value of radio button nad checkbox into a grid please give any example

regards
reena

Condor
28 Dec 2010, 1:43 AM
Getting value into a grid? What do you mean?

reena
28 Dec 2010, 1:51 AM
23990

Please see the screen and let me know how i will get which radio button and checkbox is selected

Condor
28 Dec 2010, 2:11 AM
Don't use radio or checkbox editors.

Instead use an Ext.ux.grid.CheckColumn (in examples/ux/CheckColumn.js) and an Ext.ux.grid.RadioColumn (from the User Extensions forum).

reena
28 Dec 2010, 2:26 AM
var winRoleRegister;
var frmRoleRegister;
var gridstore;
Ext.onReady(function() {
Ext.QuickTips.init();
gridstore = new Ext.data.JsonStore({
url : 'role.action?type=module',
remoteSort : false,
root : 'list',
idProperty : 'id',
fields : [{name:'modname'},{name: 'checkbox', type: 'bool'}
],
autoLoad : true
});

var answers = [
new Ext.grid.RadioColumn({header: 'Read', inputValue: 'read', id:'read',name:'read',dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Write', inputValue: 'write',id:'write',name:'write', dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Both', inputValue:'both' ,id:'both',name:'both', dataIndex: 'answer', width: 75, align: 'center', sortable: true})

];

//var rolecolumns = new Ext.grid.ColumnModel({
// columns:[
// { header:'Modules',
// dataIndex:'modname'
//
// },
// {
// //id:'assignment',
// xtype: 'checkcolumn',
// header:'Assignment',
// dataIndex:'checkbox'
//
//
// },
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
// ].concat(answers)
// });
rolegrid = new Ext.grid.EditorGridPanel({
store:gridstore,
height:200,
//cm:rolecolumns,
columns:[
{ header:'Modules',
dataIndex:'modname'

},
{
//id:'assignment',
xtype: 'checkcolumn',
header:'Assignment',
dataIndex:'checkbox'


}
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
].concat(answers),
plugins: answers


});
var roledataSet = {
xtype : 'fieldset',
autoHeight : true,
layout : 'form',
align : 'center',
items : [{
xtype : 'textfield',
fieldLabel : '<font color=#15428B><b>Role Name</font><font color=red>*</font></b>',
id : 'regRoleName',
name : 'regRoleName',
// style:'font-family:Georgia;font-size:10px;font-color:#ED7014;',
allowBlank : false,
vtype : 'alpha',
width : 200
}, {
xtype:'textfield',
fieldLabel : '<font color=#15428B><b>Role Description</b></font><font color=red>*</font>',
id : 'regRoleDescp',
name : 'regRoleDescp',
allowBlank : false,
vtype : 'alpha',
width : 200
},rolegrid]

};
frmRoleRegister = new Ext.FormPanel({
// url:'UserRegistration.action',
// method:'POST',
frame : false,
border : false,
//reader:reader,
buttonAlign : 'center',
bodyStyle : 'cellpadding:15px 15px 20px 15px 15px;',
width : 630,
labelWidth : 160,
id : 'frmRoleRegister',
items : [roledataSet],
buttonAlign : 'center',
buttons : [{
text : '<font color=#15428B size=2><b>Submit</b></font>',
id:'rolereg',
handler : function() {

var btntext = Ext.getCmp('rolereg').getText();
alert(btntext);
if(btntext == 'Update')
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=update',
method : 'POST',
//params:{getrole:vname},
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}

});
}
else
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=register',
method : 'POST',
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
//InfoStore.load();
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}
});

}

}
}

]
});


// 01. Window Register
winRoleRegister = new Ext.Window({
title : '<font color=#15428B size=4><b><center>Role Registration</center></b></font>',
id : 'winRoleRegister',
layout : 'fit',
width : 510,
height : 400,
// y: 120,
resizable : false,
closable : false,
items : [frmRoleRegister]
});
}); //end of onready



I m using the same as u said now please tell me how i will get radio and check box input value

reena
28 Dec 2010, 2:36 AM
var winRoleRegister;
var frmRoleRegister;
var gridstore;
Ext.onReady(function() {
Ext.QuickTips.init();
gridstore = new Ext.data.JsonStore({
url : 'role.action?type=module',
remoteSort : false,
root : 'list',
idProperty : 'id',
fields : [{name:'modname'},{name: 'checkbox', type: 'bool'}
],
autoLoad : true
});

var answers = [
new Ext.grid.RadioColumn({header: 'Read', inputValue: 'read', id:'read',name:'read',dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Write', inputValue: 'write',id:'write',name:'write', dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Both', inputValue:'both' ,id:'both',name:'both', dataIndex: 'answer', width: 75, align: 'center', sortable: true})

];

//var rolecolumns = new Ext.grid.ColumnModel({
// columns:[
// { header:'Modules',
// dataIndex:'modname'
//
// },
// {
// //id:'assignment',
// xtype: 'checkcolumn',
// header:'Assignment',
// dataIndex:'checkbox'
//
//
// },
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
// ].concat(answers)
// });
rolegrid = new Ext.grid.EditorGridPanel({
store:gridstore,
height:200,
//cm:rolecolumns,
columns:[
{ header:'Modules',
dataIndex:'modname'

},
{
//id:'assignment',
xtype: 'checkcolumn',
header:'Assignment',
dataIndex:'checkbox'


}
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
].concat(answers),
plugins: answers


});
var roledataSet = {
xtype : 'fieldset',
autoHeight : true,
layout : 'form',
align : 'center',
items : [{
xtype : 'textfield',
fieldLabel : '<font color=#15428B><b>Role Name</font><font color=red>*</font></b>',
id : 'regRoleName',
name : 'regRoleName',
// style:'font-family:Georgia;font-size:10px;font-color:#ED7014;',
allowBlank : false,
vtype : 'alpha',
width : 200
}, {
xtype:'textfield',
fieldLabel : '<font color=#15428B><b>Role Description</b></font><font color=red>*</font>',
id : 'regRoleDescp',
name : 'regRoleDescp',
allowBlank : false,
vtype : 'alpha',
width : 200
},rolegrid]

};
frmRoleRegister = new Ext.FormPanel({
// url:'UserRegistration.action',
// method:'POST',
frame : false,
border : false,
//reader:reader,
buttonAlign : 'center',
bodyStyle : 'cellpadding:15px 15px 20px 15px 15px;',
width : 630,
labelWidth : 160,
id : 'frmRoleRegister',
items : [roledataSet],
buttonAlign : 'center',
buttons : [{
text : '<font color=#15428B size=2><b>Submit</b></font>',
id:'rolereg',
handler : function() {

var btntext = Ext.getCmp('rolereg').getText();
alert(btntext);
if(btntext == 'Update')
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=update',
method : 'POST',
//params:{getrole:vname},
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}

});
}
else
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=register',
method : 'POST',
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
//InfoStore.load();
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}
});

}

}
}

]
});


// 01. Window Register
winRoleRegister = new Ext.Window({
title : '<font color=#15428B size=4><b><center>Role Registration</center></b></font>',
id : 'winRoleRegister',
layout : 'fit',
width : 510,
height : 400,
// y: 120,
resizable : false,
closable : false,
items : [frmRoleRegister]
});
}); //end of onready



please see the code and give solution if any?

reena
28 Dec 2010, 2:37 AM
var winRoleRegister;
var frmRoleRegister;
var gridstore;
Ext.onReady(function() {
Ext.QuickTips.init();
gridstore = new Ext.data.JsonStore({
url : 'role.action?type=module',
remoteSort : false,
root : 'list',
idProperty : 'id',
fields : [{name:'modname'},{name: 'checkbox', type: 'bool'}
],
autoLoad : true
});

var answers = [
new Ext.grid.RadioColumn({header: 'Read', inputValue: 'read', id:'read',name:'read',dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Write', inputValue: 'write',id:'write',name:'write', dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Both', inputValue:'both' ,id:'both',name:'both', dataIndex: 'answer', width: 75, align: 'center', sortable: true})

];

//var rolecolumns = new Ext.grid.ColumnModel({
// columns:[
// { header:'Modules',
// dataIndex:'modname'
//
// },
// {
// //id:'assignment',
// xtype: 'checkcolumn',
// header:'Assignment',
// dataIndex:'checkbox'
//
//
// },
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
// ].concat(answers)
// });
rolegrid = new Ext.grid.EditorGridPanel({
store:gridstore,
height:200,
//cm:rolecolumns,
columns:[
{ header:'Modules',
dataIndex:'modname'

},
{
//id:'assignment',
xtype: 'checkcolumn',
header:'Assignment',
dataIndex:'checkbox'


}
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
].concat(answers),
plugins: answers


});
var roledataSet = {
xtype : 'fieldset',
autoHeight : true,
layout : 'form',
align : 'center',
items : [{
xtype : 'textfield',
fieldLabel : '<font color=#15428B><b>Role Name</font><font color=red>*</font></b>',
id : 'regRoleName',
name : 'regRoleName',
// style:'font-family:Georgia;font-size:10px;font-color:#ED7014;',
allowBlank : false,
vtype : 'alpha',
width : 200
}, {
xtype:'textfield',
fieldLabel : '<font color=#15428B><b>Role Description</b></font><font color=red>*</font>',
id : 'regRoleDescp',
name : 'regRoleDescp',
allowBlank : false,
vtype : 'alpha',
width : 200
},rolegrid]

};
frmRoleRegister = new Ext.FormPanel({
// url:'UserRegistration.action',
// method:'POST',
frame : false,
border : false,
//reader:reader,
buttonAlign : 'center',
bodyStyle : 'cellpadding:15px 15px 20px 15px 15px;',
width : 630,
labelWidth : 160,
id : 'frmRoleRegister',
items : [roledataSet],
buttonAlign : 'center',
buttons : [{
text : '<font color=#15428B size=2><b>Submit</b></font>',
id:'rolereg',
handler : function() {

var btntext = Ext.getCmp('rolereg').getText();
alert(btntext);
if(btntext == 'Update')
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=update',
method : 'POST',
//params:{getrole:vname},
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}

});
}
else
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=register',
method : 'POST',
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
//InfoStore.load();
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}
});

}

}
}

]
});


// 01. Window Register
winRoleRegister = new Ext.Window({
title : '<font color=#15428B size=4><b><center>Role Registration</center></b></font>',
id : 'winRoleRegister',
layout : 'fit',
width : 510,
height : 400,
// y: 120,
resizable : false,
closable : false,
items : [frmRoleRegister]
});
}); //end of onready



please see the code and give any solution if any?

reena
28 Dec 2010, 2:39 AM
var winRoleRegister;
var frmRoleRegister;
var gridstore;
Ext.onReady(function() {
Ext.QuickTips.init();
gridstore = new Ext.data.JsonStore({
url : 'role.action?type=module',
remoteSort : false,
root : 'list',
idProperty : 'id',
fields : [{name:'modname'},{name: 'checkbox', type: 'bool'}
],
autoLoad : true
});

var answers = [
new Ext.grid.RadioColumn({header: 'Read', inputValue: 'read', id:'read',name:'read',dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Write', inputValue: 'write',id:'write',name:'write', dataIndex: 'answer', width: 75, align: 'center', sortable: true}),
new Ext.grid.RadioColumn({header: 'Both', inputValue:'both' ,id:'both',name:'both', dataIndex: 'answer', width: 75, align: 'center', sortable: true})

];

//var rolecolumns = new Ext.grid.ColumnModel({
// columns:[
// { header:'Modules',
// dataIndex:'modname'
//
// },
// {
// //id:'assignment',
// xtype: 'checkcolumn',
// header:'Assignment',
// dataIndex:'checkbox'
//
//
// },
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
// ].concat(answers)
// });
rolegrid = new Ext.grid.EditorGridPanel({
store:gridstore,
height:200,
//cm:rolecolumns,
columns:[
{ header:'Modules',
dataIndex:'modname'

},
{
//id:'assignment',
xtype: 'checkcolumn',
header:'Assignment',
dataIndex:'checkbox'


}
// {
// //id:'permission',
// header:'Permission',
// dataIndex:'answer'
// }
].concat(answers),
plugins: answers


});
var roledataSet = {
xtype : 'fieldset',
autoHeight : true,
layout : 'form',
align : 'center',
items : [{
xtype : 'textfield',
fieldLabel : '<font color=#15428B><b>Role Name</font><font color=red>*</font></b>',
id : 'regRoleName',
name : 'regRoleName',
// style:'font-family:Georgia;font-size:10px;font-color:#ED7014;',
allowBlank : false,
vtype : 'alpha',
width : 200
}, {
xtype:'textfield',
fieldLabel : '<font color=#15428B><b>Role Description</b></font><font color=red>*</font>',
id : 'regRoleDescp',
name : 'regRoleDescp',
allowBlank : false,
vtype : 'alpha',
width : 200
},rolegrid]

};
frmRoleRegister = new Ext.FormPanel({
// url:'UserRegistration.action',
// method:'POST',
frame : false,
border : false,
//reader:reader,
buttonAlign : 'center',
bodyStyle : 'cellpadding:15px 15px 20px 15px 15px;',
width : 630,
labelWidth : 160,
id : 'frmRoleRegister',
items : [roledataSet],
buttonAlign : 'center',
buttons : [{
text : '<font color=#15428B size=2><b>Submit</b></font>',
id:'rolereg',
handler : function() {

var btntext = Ext.getCmp('rolereg').getText();
alert(btntext);
if(btntext == 'Update')
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=update',
method : 'POST',
//params:{getrole:vname},
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}

});
}
else
{
frmRoleRegister.getForm().submit({
//url :'role.action?type=register',
method : 'POST',
waitTitle : 'Checking',
waitMsg : 'Validating ....',
success : function() {
Ext.Msg.alert('Registration Successful',
'Role has been successfully registered');
// function(btn, text) {
// if (btn == 'ok') {
//InfoStore.load();
// winRegister.hide();
// winLogin.show();
// login_form.getForm().reset();
// formRegister.getForm().reset();
// }
// });
},
failure : function(form, action) {
if (action.failureType == 'server') {
Ext.Msg.alert('Error','Registration failed due to server error');
} else { // formRegister.getForm().submit();
Ext.Msg .alert('Registration Failed','Email Id already exist or Manadatory fields are left unfilled !!!');
formRegister.getForm().reset();
}

}
});

}

}
}

]
});


// 01. Window Register
winRoleRegister = new Ext.Window({
title : '<font color=#15428B size=4><b><center>Role Registration</center></b></font>',
id : 'winRoleRegister',
layout : 'fit',
width : 510,
height : 400,
// y: 120,
resizable : false,
closable : false,
items : [frmRoleRegister]
});
}); //end of onready

please see the code and give solution if any?

Condor
28 Dec 2010, 4:23 AM
1. Please don't multi-post. Just wait until a moderator approves your post.
2. Please post code using [CODE] tags.
3. You don't need an EditorGridPanel for CheckColumns and RadioColumns. A normal GridPanel will do.
4. What exactly is the problem you are having with this code?