Ext Js 4的Radio学习与实例
来源:互联网 发布:sql注入处理 编辑:程序博客网 时间:2024/05/17 09:01
1:基本知识
Single radio field. Similar to checkbox, but automatically handles making sure only one radio is checkedat a time within a group of radios with the same name.
Labeling:In addition to the standard field labeling options, radio buttonsmay be given an optional boxLabel which will be displayed immediately to the right of the input. AlsoseeExt.form.RadioGroup for a convenient method of grouping related radio buttons.
Values:The main value of a Radio field is a boolean, indicating whether or not the radio is checked.
The following values will check the radio:true
'true'
'1'
'on'
Any other value will uncheck it.
In addition to the main boolean value, you may also specify a separate inputValue. This will be sentas the parameter value when the form is submitted. You will want to set thisvalue if you have multiple radio buttons with the samename, as is almost always the case.
2:程序代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>Ext.form.field.Radio</title><meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><link rel="stylesheet" type="text/css" href="ExtJS4/resources/css/ext-all.css" /> <script type="text/javascript" src="ExtJS4/bootstrap.js"></script> <script type="text/javascript" src="ExtJS4/ext-all.js" ></script> <script type="text/javascript" src="ExtJS4/locale/ext-lang-zh_CN.js"></script> <script type="text/javascript" > Ext.onReady(function() {Ext.create('Ext.form.Panel', { title : 'Order Form', width : 300, bodyPadding: 10, renderTo : Ext.getBody(), items: [ { xtype : 'fieldcontainer', fieldLabel : 'Size', defaultType: 'radiofield', //定义为radiofield defaults: { flex: 1 }, layout: 'hbox', items: [ { boxLabel : 'M', name : 'size', inputValue: 'm', id : 'radio1' }, { boxLabel : 'L', name : 'size', inputValue: 'l', id : 'radio2' }, { boxLabel : 'XL', name : 'size', inputValue: 'xl', id : 'radio3' } ] }, { xtype : 'fieldcontainer', fieldLabel : 'Color', defaultType: 'radiofield', defaults: { flex: 1 }, layout: 'hbox', items: [ { boxLabel : 'Blue', name : 'color', inputValue: 'blue', id : 'radio4' }, { boxLabel : 'Grey', name : 'color', inputValue: 'grey', id : 'radio5' }, { boxLabel : 'Black', name : 'color', inputValue: 'black', id : 'radio6' } ] } ], bbar: [ { text: 'Smaller Size', handler: function() { var radio1 = Ext.getCmp('radio1'), //选择各个radio的引用 radio2 = Ext.getCmp('radio2'), radio3 = Ext.getCmp('radio3'); //if L is selected, change to M if (radio2.getValue()) { radio1.setValue(true); return; } //if XL is selected, change to L if (radio3.getValue()) { radio2.setValue(true); return; } //if nothing is set, set size to S radio1.setValue(true); } }, { text: 'Larger Size', handler: function() { var radio1 = Ext.getCmp('radio1'), radio2 = Ext.getCmp('radio2'), radio3 = Ext.getCmp('radio3'); //if M is selected, change to L if (radio1.getValue()) { radio2.setValue(true); return; } //if L is selected, change to XL if (radio2.getValue()) { radio3.setValue(true); return; } //if nothing is set, set size to XL radio3.setValue(true); } }, '-', { text: 'Select color', menu: { indent: false, items: [ { text: 'Blue', handler: function() { var radio = Ext.getCmp('radio4'); radio.setValue(true); } }, { text: 'Grey', handler: function() { var radio = Ext.getCmp('radio5'); radio.setValue(true); } }, { text: 'Black', handler: function() { var radio = Ext.getCmp('radio6'); radio.setValue(true); //选中该radio } } ] } } ]});}); </script> </head> <body> </body> </html>
3:程序效果图
- Ext Js 4的Radio学习与实例
- Ext Js 4的DateField的学习与实例
- Ext Js 4 的ComboBox学习与实例
- Ext Js 4的Textarea学习与实例
- Ext Js 3.x 的FormPanel学习与简单实例
- Ext JS 4的性能与学习之我见——《Ext JS权威指南》后记
- Ext JS 学习(7) Ext.FormPanel 组件的使用第四式(CheckBox, Radio, HtmlEditor,DateField等组件)
- Ext Js4 CheckBox学习与实例
- Ext Js 3.2中的Htmleditor的实例
- Ext js的学习笔记---Ext js基础架构
- Ext Js 3.x中表格Grid的学习和实例
- ext radio
- Ext.toolbar.Toolbar的学习,是Ext Js 4的类,Ext Js3的用法有些不同
- Ext JS的Html标签与Ext组件的交互
- Ext JS 学习(4) Ext.FormPanel 组件的使用第一式
- Ext JS 学习(1) Ext.MessageBox.show()方法的使用
- Ext JS 学习(2) Ext.Panel 组件的使用
- Ext JS 学习(3) Ext.Window 组件的使用
- HTML&CSS 定位
- sql开窗函数over()用法
- 20110805
- 再次研究Jollen的mokoid工程,在模拟器上运行篇!
- ie自动 下载jre插件
- Ext Js 4的Radio学习与实例
- Codd博士提出的十二条法则
- zjut1381 字符串的编辑距离
- Add Open Command Prompt Here Functionality To Nautilus In Ubuntu
- vc中影像地面点,图像坐标,设备坐标问题
- C# winform进度条实现
- 编译器错误信息: CS0016: 未能写入输出文件 解决方法
- 給Swing組件設置提示信息的簡單例子
- c++日志类(对于c++控制台很有用的类)