CheckBox(複選框)主要用來接收用戶選擇的選項
如圖所示(請忽略UI的不好看):
該彈出窗口的主要代碼如下:
複製代碼代碼如下:
var win = new Ext.Window({
modal : true,
title : '確定要拒絕該表嗎? ',
width : 500,
plain : true,
items : [fp]
});
win.show();
彈出的窗口是載體,items裡面的[fp]是form表單的句柄。
具體定義如下:
複製代碼代碼如下:
var fp = Ext.create('Ext.FormPanel', {
frame: true,
fieldDefaults: {
labelWidth: 110
},
width: 500,
bodyPadding: 10,
items: [
{
xtype: 'fieldset',
flex: 1,
//title: '確定要拒絕該張表嗎? ',
defaultType: 'checkbox',
layout: 'anchor',
defaults: {
anchor: '100%',
hideEmptyLabel: false
},
items:[{
fieldLabel: '請選擇拒絕原因:',
boxLabel: '該表沒有填寫完整。 ',
name:'integrity',
inputValue: '1'
}, {
name:'correct',
boxLabel: '該表填寫不准確。 ',
inputValue: '1'
}]
}],
buttons: [
{text: '確認',handler: function(){
//得到完整性和準確性信息有則為1 沒有為0
if(fp.getForm().isValid()){
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
}
win.hide();
}
},{
text: '取消',
handler: function(){
win.hide();
}
}]
});
這裡面基本涵蓋了所有的感興趣的信息。具體的參見API吧本身不難
著重說下得到checkBox的值
複製代碼代碼如下:
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
這兩句話就是如何得到完整性和正確性的值。