Extjs 4.x 得到form CheckBox 復(fù)選框的值
更新時間:2014年05月04日 11:25:13 作者:
CheckBox(復(fù)選框)主要用來接收用戶選擇的選項,那么如何通過Extjs 4.x 得到form CheckBox的值呢?下面有個不錯的方法,大家值得一看
CheckBox(復(fù)選框)主要用來接收用戶選擇的選項
如圖所示(請忽略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: '該表填寫不準(zhǔn)確。',
inputValue: '1'
}]
}],
buttons: [
{text: '確認(rèn)',handler: function(){
//得到完整性和準(zhǔn)確性信息 有則為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)
這兩句話就是如何得到完整性和正確性的值。
如圖所示(請忽略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: '請選擇拒絕原因:',
boxLabel: '該表沒有填寫完整。',
name:'integrity',
inputValue: '1'
}, {
name:'correct',
boxLabel: '該表填寫不準(zhǔn)確。',
inputValue: '1'
}]
}],
buttons: [
{text: '確認(rèn)',handler: function(){
//得到完整性和準(zhǔn)確性信息 有則為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的值
復(fù)制代碼 代碼如下:
console.log(fp.getForm().findField('integrity').getValue()?1:0);
console.log(fp.getForm().findField('correct').getValue()?1:0)
這兩句話就是如何得到完整性和正確性的值。
相關(guān)文章
ExtJS4 動態(tài)生成的grid導(dǎo)出為excel示例
解決了一個表格不能重復(fù)下載的小BUG,一個使用grid初始化發(fā)生的BUG,需要的朋友可以參考下2014-05-05Extjs學(xué)習(xí)過程中新手容易碰到的低級錯誤積累
新手在學(xué)習(xí)Extjs過程中的低級錯誤積累2010-02-02Extjs中DisplayField的日期或者數(shù)字格式化擴(kuò)展
在用Extjs的時候,有時需要對 Ext.form.DisplyField 進(jìn)行格式化。2010-09-09常用Extjs工具:Extjs.util.Format使用方法
常用Extjs工具:Extjs.util.Format使用方法,需要的朋友可以參考下2012-03-03extjs grid設(shè)置某列背景顏色和字體顏色的實現(xiàn)方法
extjs grid設(shè)置某列背景顏色和字體顏色的實現(xiàn)步驟,需要的朋友可以參考下。2010-09-09關(guān)于extjs treepanel復(fù)選框選中父節(jié)點與子節(jié)點的問題
實現(xiàn)帶有復(fù)選框的樹,選中父節(jié)點時,選中所有子節(jié)點。取消所有子節(jié)點時,才能取消根節(jié)點,感興趣的朋友可以了解下本文2013-04-04ext前臺接收action傳過來的json數(shù)據(jù)示例
這篇文章以示例的方式為大家介紹了ext前臺接收action傳過來的json數(shù)據(jù),需要的朋友可以參考下2014-06-06