日期:2014-05-16  浏览次数:20894 次

求教 Ext.form.radiogroup提交问题 - Web 开发 / Ajax
我用Ext做了个注册 想在提交的时候判断下radiogroup如果没选 弹出个alert提示下 请教怎么实现

------解决方案--------------------
Ext.define('MyApp.view.ui.MyForm', {
extend: 'Ext.form.Panel',

id: 'myform',
layout: {
type: 'auto'
},
bodyPadding: 10,
title: '',
region: 'center',

initComponent: function() {
var me = this;
me.items = [
{
xtype: 'radiogroup',
height: 33,
width: 501,
fieldLabel: '',
allowBlank: false,
blankText: 'must input item!',
items: [
{
xtype: 'radiofield',
id: 'man',
name: 'sex',
value: 0,
fieldLabel: '',
boxLabel: '男'
},
{
xtype: 'radiofield',
id: 'woman',
name: 'sex',
value: 1,
fieldLabel: '',
boxLabel: '女'
}
]
},
{
xtype: 'button',
id: 'insert',
text: 'insert'
}
];
me.callParent(arguments);
}
});

----------------Ridio Group 的属性-----------
allowBlank: false,
blankText: 'must input item!',
----------------------------------------------
----------------提交按钮事件------------------
function onBtnClickInsert(){
var form = Ext.getCmp("myform").getForm();

if(form.isValid()) return;
};
----------------------------------------------
如果Ridio一个也没选的话,Ridio Group控件会加红框,鼠标放到上面的话,【'must input item!'】会被显示。这样做如何呢?仅供参考。
------解决方案--------------------
或者你加个默认选中项,就不用CHECK了。
{
xtype: 'radiofield',
id: 'man',
name: 'sex',
value: 0,
fieldLabel: '',
boxLabel: '男',
checked: true
},
------解决方案--------------------
或者加个默认选中项,就不用CHECK了。
{
xtype: 'radiofield',
id: 'man',
name: 'sex',
value: 0,
fieldLabel: '',
boxLabel: '男',
checked: true
},