items: {
xtype: 'fieldset',
title: 'Individual Radios',
autoHeight: true,
defaultType: 'radio', // each item will be a radio button
items: [{
xtype: 'textfield',
name: 'txt-test2',
fieldLabel: 'Alignment Test'
}, {
fieldLabel: 'Favorite Color',
boxLabel: 'Red',
name: 'fav-color',
inputValue: 'red'
}, {
fieldLabel: '',
labelSeparator: '',
boxLabel: 'Blue',
name: 'fav-color',
inputValue: 'blue'
}, {
fieldLabel: '',
labelSeparator: '',
boxLabel: 'Green',
name: 'fav-color',
inputValue: 'green'
}]
}
在客户端验证时单选框不能为空.应该怎么写.
allowBlank: false,找了半天我也不知道加在什么地方
[b]问题补充:[/b]
需求就是没有默认数值...怎么搞啊
都说了,用radiogroup....
示例代码:
[code="javascript"]
Ext.onReady(function(){
Ext.BLANK_IMAGE_URL = '/images/s.gif';
Ext.QuickTips.init();
testFormValid();
});
function testFormValid(){
var f = new Ext.form.FormPanel({
height:300,
width:500,
renderTo:document.body,
items:[
{
xtype: 'radiogroup',
fieldLabel: 'Auto Layout',
allowBlank:false,
items: [
{boxLabel: 'Item 1', name: 'rb-auto', inputValue: 1},
{boxLabel: 'Item 2', name: 'rb-auto', inputValue: 2},
{boxLabel: 'Item 3', name: 'rb-auto', inputValue: 3},
{boxLabel: 'Item 4', name: 'rb-auto', inputValue: 4},
{boxLabel: 'Item 5', name: 'rb-auto', inputValue: 5}
]
},
{
xtype:'button',
text:'submit',
handler:function(){
f.getForm().submit({
url: 'updateConsignment.php',
clientValidation: true,
failure: function(form, action) {
switch (action.failureType) {
case Ext.form.Action.CLIENT_INVALID:
Ext.Msg.alert('失败', '验证失败');
break;
}
}
})
}
}
]
});
}
[/code]
变通一下撒,默认选中一个就可以了
1.用Ext.form.RadioGroup,有allowBlank : Boolean
2.或者提交的时候手动验证吧
Radio 没有 allowBlank: false
[quote]需求就是没有默认数值...怎么搞啊 [/quote]
这个应该没什么关系..反正你不能为空...都得选一个,你选后,默认的勾自然没掉,如果选的就是默认的话,那就不要点了...