Extjs中checkbox和radio的使用的小例子
来源:互联网 发布:sai绘画软件 编辑:程序博客网 时间:2024/04/29 06:17
文件:edit.js
Ext.define('BOOK.view.Edit', { extend: 'Ext.container.Container', alias : 'widget.bookEdit', layout:'border',//采用fit布局 /** 初始化方法 */ initComponent: function() { this.items = [this.CheckBoxAndRadio()]; this.callParent(arguments); }, /*---------------------复选和单选按钮-----------------*/ CheckBoxAndRadio: function(){ this.queryFieldForm = Ext.create("Ext.form.Panel",{ id: 'checkBoxAndRadioForm' ,name: 'checkBoxAndRadioForm' ,margin: 1 ,region: 'north' ,layout: "column" ,tbar: [ {xtype: 'button' ,text: '输出多选数据' ,id: 'outputCheckBox' }, '-', {xtype : 'button', text : '输出单选数据', id : 'outputRadio'}] ,items:[ {xtype:'checkboxgroup',name:'checkboxgroup', id: 'checkboxgroup', fieldLabel: 'Two Columns',columnWidth:0.7, items: [ { boxLabel: 'Item 1', name: 'cb', inputValue: '1' }, { boxLabel: 'Item 2', name: 'cb', inputValue: '2' }, { boxLabel: 'Item 3', name: 'cb', inputValue: '3' }, { boxLabel: 'Item 4', name: 'cb', inputValue: '4' }, { boxLabel: 'Item 5', name: 'cb', inputValue: '5' }, { boxLabel: 'Item 6', name: 'cb', inputValue: '6' } ]} ,{xtype:'radiogroup', name:'radiogroup', fieldLabel:'radios', columnWidth:0.7,items: [ { boxLabel: 'Item 1', name: 'rb', inputValue: '1' ,id: 'radiogroup'}, { boxLabel: 'Item 2', name: 'rb', inputValue: '2' }, { boxLabel: 'Item 3', name: 'rb', inputValue: '3' }, { boxLabel: 'Item 4', name: 'rb', inputValue: '4' }, { boxLabel: 'Item 5', name: 'rb', inputValue: '5' }, { boxLabel: 'Item 6', name: 'rb', inputValue: '6' } ]} ] }); return this.queryFieldForm; } });
Ext.define('BOOK.controller.BookCtrl', {extend: 'Ext.app.Controller', views: [//控制器的视图列表 'Edit' ], init: function() {this.control({// 输出'#outputCheckBox': {click: this.outputCheckBox},'#outputRadio': {click: this.outputRadio} }); } // 输出多选数据 ,outputCheckBox: function(){ var itcIds = ''; var cbgItem = Ext.getCmp('checkboxgroup').getChecked(); Ext.Array.each(cbgItem, function(item){ itcIds = itcIds + ',' + item.inputValue; }); Ext.MessageBox.alert('提示', '您选择的是' + itcIds); } // 输出单选数据 ,outputRadio: function(){ Ext.MessageBox.alert(Ext.getCmp('radiogroup').getGroupValue()); } });
运行的效果图:
1、要为第一个radio指定id属性;
2、同一个radiogroup中的radio的name的值必须相同!
好吧,我就是死在了第二条上。。。希望大家不要在这两点上花太多时间!
- Extjs中checkbox和radio的使用的小例子
- JQuery中对Radio和CheckBox的对比使用
- jquery中radio,CheckBox使用attr和prop的区别
- 解决Extjs 中,radio 和 checkbox 文字纵向排列的css
- radio和checkbox例子
- js中radio和checkbox中选中状态的判断
- radio和checkbox中使用 label
- jQuery中radio和checkbox的选中的另一种方式
- jQuery中radio和checkbox的选中的另一种方式
- Jquery -- 常用选择器 和 div/select/radio/checkbox的使用
- 对于单选框radio和复选框checkbox的使用
- ExtJs之Radio和CheckBox实例
- HTML select ,radio的使用,checkbox全选
- checkbox radio 多选框单选框中jquery的使用问题
- js获取radio/checkbox内容的的两个例子
- Extjs RadioGroup中Radio的切换
- Extjs RadioGroup中Radio的切换
- checkbox,radio的传值和标签
- linux ocr 识别
- yii booter扩展手记
- Hibernate学习(一)--Hibernate知识要点3
- Android入门之控件布局初步
- Silverlight for Windows Phone开发系列课程
- Extjs中checkbox和radio的使用的小例子
- Hibernate学习(一)--Hibernate知识要点4
- android模拟器浏览图片、视频的操作方法,创建和使用SDCard
- 长期资产
- 将war文件配置成网页
- vTiger 5.4.0 从远程服务器下载源代码的安装方式
- SOS
- HDU1099-概率论题
- xcode的环境变量,Build Settings参数,workspace及联编设置