【ExtJs】 ExtJs4.2 基本表单组件的使用
包含ExtJs 基本的组件radioGroup,ComboBox,File,NumberField...
<%--
Created by IntelliJ IDEA.
User: Administrator
Date: 2015/12/30 0030
Time: 13:35
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<jsp:include page="resource.jsp"></jsp:include>
<title>表单常用组件</title>
</head>
<body> <script type="text/javascript">
Ext.onReady(function(){ //tore 也可以加载内部指定的数据. 在内部, Store 将我们传入的对象作为data,转换为Model实例。
Ext.define('Movie', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'},
{name: 'url', type: 'string'}
]
});
//加载一个嵌套的数据集合(nested dataset)并可以让Reader自动的生成相关的model
var states = Ext.create("Ext.data.Store",{
model: 'Movie',
proxy: {
type: 'ajax',
url: 'movie.json',//指定的链接
reader: {
type: 'json',
root: 'movies'
}
},
autoLoad: true
}); var form = new Ext.form.Panel({
title: '基本表单',
bodyPadding: 5,
width: 750,
// 表单域 Fields 将被竖直排列, 占满整个宽度
layout: 'anchor',
defaults: {
anchor: '100%'
}, url:"form.jsp",//提交至指定的url
// The fields
defaultType: 'textfield',
items: [{
fieldLabel: '用户名',
name: 'name',
allowBlank: false,//是否为空
blankText:'用户名不能为空' },{
fieldLabel: '密码',
name: 'passwd',
inputType:'password',
allowBlank: false,
blankText:"密码不能为空"
},{
fieldLabel:"性别",
xtype: 'radiogroup',
columns:2,//两列
vertical: false,
items: [
{ boxLabel: '男', name: 'sex', inputValue: '1',disabled:true },//一组Ext.form.Radio对象
{ boxLabel: '女', name: 'sex', inputValue: '2', checked: true}
]
},
{
fieldLabel: '喜欢的电影类型',
store: states,
name:'movieType',
xtype:"combo",
queryMode: 'local',
displayField: 'name',
valueField: 'id',
renderTo: Ext.getBody()
},
{
xtype: 'checkboxgroup',
fieldLabel: '爱好',
columns: 3,
vertical: true,
items: [
{ boxLabel: 'IT', name: 'fav', inputValue: '1' },
{ boxLabel: '美女', name: 'fav', inputValue: '2', checked: true },
{ boxLabel: '建筑', name: 'fav', inputValue: '3' },
{ boxLabel: '新闻', id:"news", name: 'fav', inputValue: '4',handler:getCheckBox},// 点击后触发的事件
{ boxLabel: '体育', name: 'fav', inputValue: '5' },
{ boxLabel: '军事', name: 'fav', inputValue: '6' },
{ boxLabel: '亲子', name: 'fav', inputValue: '7' }
]
},{
xtype: 'datefield',
fieldLabel: '出生日期',
name: 'birth',
editable:false
//value: new Date() // 设置默认值
},{
xtype: 'numberfield',
anchor: '100%',
name: 'salary',
fieldLabel: '薪水',
value: 4999,
// maxValue: 99999,
minValue: 0
},{
xtype: 'filefield',
name: 'resume',
fieldLabel: '个人简历',
labelWidth:70,
msgTarget: 'side',
allowBlank: false,
anchor: '100%',
buttonText: '选择要上传的文件'
},{
xtype: 'htmleditor',
fieldLabel: '个人评价',
name:"personal",
enableColors: true,//启用选择颜色按钮
enableFont:true,//启用选择字体按钮
enableAlignments: true,//启用样式对齐按钮
enableLinks : true,// 启用链接创建按钮,默认为true
createLinkText: '创建超链接',//创建连接的提示信息
value:"<b>ExtJs基础学习</b>",
fontFamilies:['宋体','隶书','黑体']//字体列表 }], // 重置 和 保存 按钮.
buttons: [{
text: '重置',
handler: function() {
this.up('form').getForm().reset();
}
}, {
text: '保存',
formBind: true, //only enabled once the form is valid
disabled: true,
handler: function() {
var form = this.up('form').getForm();
if (form.isValid()) {
form.submit({
success: function(form, action) {
Ext.Msg.alert('保存成功', action.result.msg);
},
failure: function(form, action) {
Ext.Msg.alert('操作失败', action.result.msg);
}
});
}
}
}],
renderTo: Ext.getBody()
}); function getCheckBox(){
Ext.Msg.alert("提示","你不能选择该选项");
Ext.getCmp("news").setValue("");
} });
</script> </body>
</html>
movie.json:
{
"movies": [{
"id": 1,
"name": "恐怖片",
"url":"http://www.google.com"
},
{
"id": 2,
"name": "科幻片",
"url":"http://www.baidu.com"
},
{
"id":3,
"name": "喜剧片",
"url":"http://www.xj.com"
}]
}
效果图如下:

【ExtJs】 ExtJs4.2 基本表单组件的使用的更多相关文章
- reactjs入门到实战(八)----表单组件的使用
表单组件支持几个受用户交互影响的属性: value,用于 <input>.<textarea> 组件. checked,用于类型为 checkbox 或者 radio 的 &l ...
- ReactJS实用技巧(2):从新人大坑——表单组件来看State
不太清楚有多少初学React的同学和博主当时一样,在看完React的生命周期.数据流之后觉得已经上手了,甩开文档啪啪啪的开始敲了起来.结果...居然被一个input标签给教做人了. 故事是这样的:首先 ...
- 【form】 表单组件说明
form表单组件 1)将form组件内的用户输入的<switch/> <input/> <checkbox/> <slider/> <radio/ ...
- 通过html()的方法获取文本内容, form表单组件显示的值与获取到的值不一致的问题
我在通过 html()获取对应节点的内容,发现一个问题,获取到的 form表单组件的内容值是初始加载的值,而不是经过用户修改后的值.例如页面加载时组件<input type="text ...
- 如何实现Ant design表单组件封装?
目标:自己实现一个antd表单组件 先看下Ant Design官网上给出的表单组件用法: import React, { Component } from 'react' import { Form, ...
- django基础之day09,创建一个forms表单组件进行表单校验,知识点:error_messages,label,required,invalid,局部钩子函数,全局钩子函数, forms_obj.cleaned_data,forms_obj.errors,locals(), {{ forms.label }}:{{ forms }},{{ forms.errors.0 }}
利用forms表单组件进行表单校验,完成用户名,密码,确认密码,邮箱功能的校验 该作业包含了下面的知识点: error_messages,label,required,invalid,局部钩子函数,全 ...
- 使用iview 的表单组件验证 Upload 组件
使用iview 的表单组件验证 Upload 组件 结果: 点击提交按钮, 没有填的form 项, 提示错误, 当填入数据后提示验证成功 代码: <template> <div id ...
- 文档驱动 —— 表单组件(五):基于Ant Design Vue 的表单控件的demo,再也不需要写代码了。
源码 https://github.com/naturefwvue/nf-vue3-ant 特点 只需要更改meta,既可以切换表单 可以统一修改样式,统一升级,以最小的代价,应对UI的升级.切换,应 ...
- 文档驱动 —— 表单组件(六):基于AntDV的Form表单的封装,目标还是不写代码
开源代码 https://github.com/naturefwvue/nf-vue3-ant 也不知道大家是怎么写代码的,这里全当抛砖引玉 为何封装? AntDV非常强大,效果也非常漂亮,功能强大, ...
随机推荐
- strcat
将两个char类型链接. char d[20]="GoldenGlobal"; char *s="View"; strcat(d,s); 结果放在d中 prin ...
- layer返璞归真
返璞归真 前端社区正在变得日渐喧嚣,我们似乎很难停下追逐的脚步.而Layui偏偏回望当初,奔赴在返璞归真的漫漫征途,自信并勇敢着,追寻于原生态的书写指令,试图以最简单的方式诠释高效
- java Spring 事务的初次使用与验证
事务,只要是为了保证数据的原子性.避免出现脏数据. 下面来讲解下spring是如何使用事务的. 1.配置事务.这里采用的是注解的模式 <!-- 配置事务管理器 ,如果你暂时未使用到事务可以不配置 ...
- GIS+=地理信息+行业+大数据——基于云环境流处理平台下的实时交通创新型app
应用程序已经是近代的一个最重要的IT创新.应用程序是连接用户和数据之间的桥梁,提供即时訪问信息是最方便且呈现的方式也是easy理解的和令人惬意的. 然而,app开发人员.尤其是后端平台能力,一直在努力 ...
- 跨服务器sql操作
1.打开跨服务器功能 exec sp_configure 'show advanced options',1 reconfigure exec sp_configure 'Ad Hoc Distrib ...
- C语言 · 寂寞的数
算法训练 寂寞的数 时间限制:1.0s 内存限制:256.0MB 问题描述 道德经曰:一生二,二生三,三生万物. 对于任意正整数n,我们定义d(n)的值为为n加上组成n的各个数字的和 ...
- [uart]UART中的硬件流控RTS与CTS
转自:http://blog.csdn.net/zeroboundary/article/details/8966586 在RS232中本来CTS 与RTS 有明确的意义,但自从贺氏(HAYES ) ...
- c++的内存分配
C++堆和栈的分配 腾讯.金山笔试常考 栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部变量的值等,其操作方式类似于数据结构中的栈. 堆区(heap) — 一般由程序员分配释放, ...
- 去除idea15重复代码校验
- Android—— 线程 thread 两种实现方法!(转)
原文地址:http://blog.csdn.net/boyupeng/article/details/6208072 这篇文章中有三点需要提前说明一下, 一: 在android中有两种实现线程thre ...