Extjs 4.x 得到form CheckBox 復(fù)選框的值
更新時(shí)間:2014年05月04日 11:25:13 作者:
CheckBox(復(fù)選框)主要用來(lái)接收用戶選擇的選項(xiàng),那么如何通過(guò)Extjs 4.x 得到form CheckBox的值呢?下面有個(gè)不錯(cuò)的方法,大家值得一看
CheckBox(復(fù)選框)主要用來(lái)接收用戶選擇的選項(xiàng)
如圖所示(請(qǐng)忽略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: '請(qǐng)選擇拒絕原因:',
boxLabel: '該表沒(méi)有填寫(xiě)完整。',
name:'integrity',
inputValue: '1'
}, {
name:'correct',
boxLabel: '該表填寫(xiě)不準(zhǔn)確。',
inputValue: '1'
}]
}],
buttons: [
{text: '確認(rèn)',handler: function(){
//得到完整性和準(zhǔn)確性信息 有則為1 沒(méi)有為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();
}
}]
});
這里面基本涵蓋了所有的感興趣的信息。具體的參見(jiàn)API吧本身不難
著重說(shuō)下得到checkBox的值
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
這兩句話就是如何得到完整性和正確性的值。
如圖所示(請(qǐng)忽略UI的不好看):

該彈出窗口的主要代碼如下:
復(fù)制代碼 代碼如下:
var win = new Ext.Window({
modal : true,
title : '確定要拒絕該表嗎?',
width : 500,
plain : true,
items : [fp]
});
win.show();
彈出的窗口是載體,items里面的[fp]是form表單的句柄。
具體定義如下:
復(fù)制代碼 代碼如下:
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: '請(qǐng)選擇拒絕原因:',
boxLabel: '該表沒(méi)有填寫(xiě)完整。',
name:'integrity',
inputValue: '1'
}, {
name:'correct',
boxLabel: '該表填寫(xiě)不準(zhǔn)確。',
inputValue: '1'
}]
}],
buttons: [
{text: '確認(rèn)',handler: function(){
//得到完整性和準(zhǔn)確性信息 有則為1 沒(méi)有為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();
}
}]
});
這里面基本涵蓋了所有的感興趣的信息。具體的參見(jiàn)API吧本身不難
著重說(shuō)下得到checkBox的值
復(fù)制代碼 代碼如下:
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
這兩句話就是如何得到完整性和正確性的值。
相關(guān)文章
ExtJS 2.2.1的grid控件在ie6中的顯示問(wèn)題
最近在學(xué)習(xí)使用ExtJS進(jìn)行富客戶端開(kāi)發(fā)。使用ExtJS 2.2.1的grid控件時(shí),發(fā)現(xiàn)在ie6中運(yùn)行存在一個(gè)問(wèn)題2009-05-05
extjs4 treepanel動(dòng)態(tài)改變行高度示例
本文為大家介紹下extjs4 treepanel如何動(dòng)態(tài)改變行高度,下面有個(gè)不錯(cuò)的示例,感興趣的朋友可以參考下2013-12-12
ExtJS 設(shè)置級(jí)聯(lián)菜單的默認(rèn)值
ExtJS在修改這樣的頁(yè)面上賦值是很方便的,在正文中1.2.1代碼中可以看出,一行代碼就可以搞定,但這是對(duì)于普通控件而言,如文本框。對(duì)于ComboBox可沒(méi)這么簡(jiǎn)單...2010-06-06
ExtJS[Desktop]實(shí)現(xiàn)圖標(biāo)換行示例代碼
ExtJS中的desktop的demo中,默認(rèn)的圖標(biāo)排列是不換行的,以下代碼就是為了解決這一問(wèn)題的,需要的朋友可以了解下2013-11-11

