ExtJS表单之复选框CheckboxGroup展示与取值
来源:互联网 发布:淘宝竞品分析报告 编辑:程序博客网 时间:2024/05/22 14:06
版本一
复选框的值都是直接指定。
版本二
复选框的值也可以动态指定
复选框的值都是直接指定。
- Ext.onReady(function(){
- var myCheckboxGroup = new Ext.form.CheckboxGroup({
- id:'myGroup',
- xtype: 'checkboxgroup',
- renderTo :'form-cb',
- fieldLabel: 'Single Column',
- itemCls: 'x-check-group-alt',
- columns: 3,
- items: [
- {boxLabel: '唱歌', name: '1'},
- {boxLabel: '游泳', name: '2', checked: true},
- {boxLabel: '看书', name: '3'},
- {boxLabel: '旅游', name: '4'},
- {boxLabel: '游戏', name: '5'},
- {boxLabel: '睡觉', name: '6'}
- ]
- });
- //CheckboxGroup取值方法
- for (var i = 0; i < myCheckboxGroup.items.length; i++)
- {
- if (myCheckboxGroup.items.itemAt(i).checked)
- {
- alert(myCheckboxGroup.items.itemAt(i).name);
- }
- }
- });
Ext.onReady(function(){ var myCheckboxGroup = new Ext.form.CheckboxGroup({ id:'myGroup', xtype: 'checkboxgroup', renderTo :'form-cb', fieldLabel: 'Single Column', itemCls: 'x-check-group-alt', columns: 3, items: [ {boxLabel: '唱歌', name: '1'}, {boxLabel: '游泳', name: '2', checked: true}, {boxLabel: '看书', name: '3'}, {boxLabel: '旅游', name: '4'}, {boxLabel: '游戏', name: '5'}, {boxLabel: '睡觉', name: '6'} ] }); //CheckboxGroup取值方法 for (var i = 0; i < myCheckboxGroup.items.length; i++) { if (myCheckboxGroup.items.itemAt(i).checked) { alert(myCheckboxGroup.items.itemAt(i).name); } } });
- // 复选框
- var myCheckboxGroup = new Ext.form.CheckboxGroup({
- xtype: 'checkboxgroup',
- name: 'model_type',
- width: 80, //宽度220
- columns: 1, //在上面定义的宽度上展示3列
- fieldLabel: '机型类型cb',
- items: [
- {boxLabel: '存储机型', name: 'store'},
- {boxLabel: '均衡机型', name: 'average'},
- {boxLabel: '其他机型', name: 'other'}
- ]
- });
- // 2,收集复选框的值
- var ids = [];
- var cbitems = myCheckboxGroup.items;
- for (var i = 0; i < cbitems.length; i++) {
- if (cbitems.itemAt(i).checked) {
- ids.push(cbitems.itemAt(i).name);
- }
- }
// 复选框var myCheckboxGroup = new Ext.form.CheckboxGroup({xtype: 'checkboxgroup',name: 'model_type',width: 80, //宽度220columns: 1, //在上面定义的宽度上展示3列fieldLabel: '机型类型cb',items: [{boxLabel: '存储机型', name: 'store'},{boxLabel: '均衡机型', name: 'average'},{boxLabel: '其他机型', name: 'other'}]});// 2,收集复选框的值var ids = [];var cbitems = myCheckboxGroup.items; for (var i = 0; i < cbitems.length; i++) { if (cbitems.itemAt(i).checked) { ids.push(cbitems.itemAt(i).name); } }
版本二
复选框的值也可以动态指定
- DoctorWorkStation_CommonDoctorAdvice.CreateYZCheckBoxWin = function(store, colnum,title) {
- var count = store.getCount();
- var myCheckboxItems = [];
- for (var i = 0; i < count; i++) {
- var boxLabel = store.getAt(i).get("name");
- var name = store.getAt(i).get("id");
- myCheckboxItems.push({
- boxLabel : boxLabel,
- name : name
- });
- }
- var myCheckboxGroup = new Ext.form.CheckboxGroup({
- xtype : 'checkboxgroup',
- itemCls : 'x-check-group-alt',
- columns : colnum,
- items : myCheckboxItems
- });
- var form = new Ext.FormPanel({
- border : true,
- frame : true,
- labelAlign : "right",
- buttonAlign : 'right',
- layout : 'column',
- width : 500,
- items : [myCheckboxGroup],
- buttons : [{
- xtype : 'button',
- text : '确定',
- handler : function() {
- var ids = [];
- var cbitems = myCheckboxGroup.items;
- for (var i = 0; i < cbitems.length; i++) {
- if (cbitems.itemAt(i).checked) {
- ids.push(cbitems.itemAt(i).name);
- }
- }
- win.destroy();
- if (ids.length) {
- Ext.Msg.alert("消息", "选中状态的id组合字符串为:"
- + ids.toString());
- }
- }
- }, {
- xtype : 'button',
- text : '取消',
- handler : function() {
- win.destroy();
- }
- }]
- });
- var win = new Ext.Window({
- modal : true,
- layout : 'fit',
- title : title,
- width : 500,
- height : 300,
- plain : true,
- items : [form]
- });
- win.show();
- }
DoctorWorkStation_CommonDoctorAdvice.CreateYZCheckBoxWin = function(store, colnum,title) { var count = store.getCount(); var myCheckboxItems = []; for (var i = 0; i < count; i++) { var boxLabel = store.getAt(i).get("name"); var name = store.getAt(i).get("id"); myCheckboxItems.push({ boxLabel : boxLabel, name : name }); } var myCheckboxGroup = new Ext.form.CheckboxGroup({ xtype : 'checkboxgroup', itemCls : 'x-check-group-alt', columns : colnum, items : myCheckboxItems }); var form = new Ext.FormPanel({ border : true, frame : true, labelAlign : "right", buttonAlign : 'right', layout : 'column', width : 500, items : [myCheckboxGroup], buttons : [{ xtype : 'button', text : '确定', handler : function() { var ids = []; var cbitems = myCheckboxGroup.items; for (var i = 0; i < cbitems.length; i++) { if (cbitems.itemAt(i).checked) { ids.push(cbitems.itemAt(i).name); } } win.destroy(); if (ids.length) { Ext.Msg.alert("消息", "选中状态的id组合字符串为:" + ids.toString()); } } }, { xtype : 'button', text : '取消', handler : function() { win.destroy(); } }] }); var win = new Ext.Window({ modal : true, layout : 'fit', title : title, width : 500, height : 300, plain : true, items : [form] }); win.show(); }
转自:http://zccst.iteye.com/blog/1243281
- ExtJS表单之复选框CheckboxGroup展示与取值
- Extjs checkboxgroup 取值
- ExtJS 获取复选框的值 checkboxgroup 获取值 fieldset(checkbox) 获取值
- ExtJs中checkboxgroup复选框组件的显示问题
- 工作记录1:extJS-checkboxgroup复选框和combo联动
- ExtJs实现复选框组Checkboxgroup单勾选及复选框组对多个复选框组跨控件全选
- extjs tree checkbox 复选框实现 取值 显示
- extjs tree checkbox 复选框实现 取值 显示
- ExtJs 入门教程九[单选组:RadioGroup、复选组:CheckBoxGroup]
- ExtJs 入门教程十[单选组:RadioGroup、复选组:CheckBoxGroup]
- 无废话ExtJs 入门教程十[单选组:RadioGroup、复选组:CheckBoxGroup]
- ExtJS05:动态构造复选框组CheckboxGroup
- ExtJS 获取radioGroup及CheckboxGroup值
- ExtJS4新发现10_获取复选框(checkboxgroup&checkbox)的值
- ExtJs之treePanel checkbox 复选框
- Ext---CheckBoxGroup的取值和赋值
- 关于复选框的验证与jsp取值(转载)
- 复选框的取值与验证(checkbox)
- 13年省赛总结
- 判断外部存储是SD卡还是u盘的方法
- UNIX环境高级编程读书笔记(九)—进程关系 (1)
- 一点一滴的培养你的领导气质
- 调用FileSystemObject.CopyFile发生没有权限的错误
- ExtJS表单之复选框CheckboxGroup展示与取值
- C++中的单例模式
- jquery map方法
- c++设计一个类,但是不能被继承
- 双绞线的标准接法
- IntelliJ Idea 常用快捷键列表 .
- ios 美元飘落效果的demo
- java.lang.IllegaAccessError:Class ref in pre-verified class resoved to unexpected implementation
- 学会你就是半仙!古代识人术!!