ExtJs之Ext.view.View
要注意MODEL的定义和实例化的代码,注释掉的是老式的不兼容4.0以上的。而下面的定义才是新推荐的。
我网上可是查的了。是书上的代码老了。
<!DOCTYPE html>
<html>
<head>
<title>ExtJs</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" type="text/css" href="ExtJs/packages/ext-theme-crisp/build/resources/ext-theme-crisp-all.css">
<script type="text/javascript" src="ExtJs/ext-all.js"></script>
<script type="text/javascript" src="ExtJs/bootstrap.js"></script>
<script type="text/javascript" src="ExtJs/packages/ext-theme-crisp/build/ext-theme-crisp.js"></script>
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
var inputForm = Ext.create('Ext.form.Panel', {
bodyPadding: 5,
width: 600,
flex: 1,
fieldDefaults: {
labelSeparator: ': ',
labelWidth: 80,
width: 180,
msgTarget: 'side',
allowBlank: false,
labelAlign: 'right'
},
layout: {
type: 'hbox',
align: 'middle'
},
defaultType: 'textfield',
items: [{
fieldLabel: '产品名称',
name: 'productName'
},{
fieldLabel: '数量',
xtype: 'numberfield',
name: 'productNum'
},{
fieldLabel: '金额',
xtype: 'numberfield',
name: 'productPrice'
}],
fbar: [{
text: '增加',
handler: function(){
if(inputForm.getForm().isValid()){
var data = inputForm.getForm().getValues();
//var product = Ext.ModelMgr.create(data, 'ProductInfo');
var product = Ext.create('ProductInfo', data);
productStore.add(product);
inputForm.getForm().reset();
}
}
}]
});
//Ext.regModel('ProductInfo', {
// fields: ['productName', 'productNum', 'productPrice']
//});
Ext.define('ProductInfo', {
extend: 'Ext.data.Model',
fields: [
{name: 'productName'},
{name: 'productNum'},
{name: 'productPrice'}
]
});
var productStore = Ext.create('Ext.data.Store', {
autoLoad: true,
data: [],
model: 'ProductInfo',
proxy: {
type: 'memory',
reader: {
type: 'json',
rootProperty: 'datas'
}
}
});
var productTpl = new Ext.XTemplate(
'<table border=1 cellspacing=1 cellpadding=1 width=100%>',
'<tr><td width=160>产品名称</td><td width=75>数量</td><td width=75>金额</td></tr>',
'<tpl for=".">',
'<tr><td>{productName}</td><td>{productNum}</td><td>{productPrice}</td></tr>',
'</tpl>',
'</table>'
);
var productView = Ext.create('Ext.view.View', {
store: productStore,
tpl: productTpl,
deferEmptyText: false,
itemSelector: 'div.thumb-wrap',
emptyText: '请录入商品'
});
var productViewPanel = Ext.create('Ext.panel.Panel', {
autoScroll: true,
width: 600,
flex: 3,
layout: 'fit',
bodyStyle: 'background-color: #FE5623',
items: productView
});
Ext.create('Ext.panel.Panel', {
renderTo: document.body,
frame: true,
width: 800,
height:500,
layout: 'vbox',
title: '产品录入',
items: [inputForm, productViewPanel]
});
});
</script>
</head>
<body>
<div id='tpl-table1'></div>
<br>
<div id='tpl-table2'></div>
</body>
</html>

ExtJs之Ext.view.View的更多相关文章
- [转载]ExtJs4 笔记(11) Ext.ListView、Ext.view.View 数据视图
本篇介绍两个用来展示数据的容器控件,分别是Ext.ListView和Ext.view.View.Ext.ListView就是大名鼎鼎的 Ext GridPanel的前身,不过现在的Ext4已经将它整合 ...
- ExtJs4 笔记(11) Ext.ListView、Ext.view.View 数据视图
本篇介绍两个用来展示数据的容器控件,分别是Ext.ListView和Ext.view.View.Ext.ListView就是大名鼎鼎的Ext GridPanel的前身,不过现在的Ext4已经将它整合到 ...
- ExtJS学习-----------Ext.Array,ExtJS对javascript中的Array的扩展
关于ExtJS对javascript中的Array的扩展.能够參考其帮助文档,文档下载地址:http://download.csdn.net/detail/z1137730824/7748893 因为 ...
- ExtJS学习-----------Ext.Object,ExtJS对javascript中的Object的扩展
关于ExtJS对javascript中的Object的扩展.能够參考其帮助文档,文档下载地址:http://download.csdn.net/detail/z1137730824/7748893 以 ...
- Android 拖动View View跟随手指一动
/** * 拖动View 配合onTouchListener使用 * 设置View的布局属性,使得view随着手指移动 注意:view所在的布局必须使用RelativeLayout 而且不得设置居中等 ...
- public void onItemClick(AdapterView arg0, View view, int position,long arg3)详解【整理自网络】
参考自: http://blog.csdn.net/zwq1457/article/details/8282717 http://blog.iamzsx.me/show.html?id=147001 ...
- ListView onItemClick(AdapterView<?> parent, View view, int position, long id)参数详解
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { parent.getA ...
- Android API之android.view.View.MeasureSpec
android.view.View.MeasureSpec MeasureSpec是View的内部类 public static class MeasureSpec MeasureSpec封装从par ...
- onItemClick(AdapterView<?> parent, View view, int position, long id)
Public Methods public abstract void onItemClick (AdapterView<?> parent, View view, int positio ...
随机推荐
- hihocoder 1680 hiho字符串2 dp求方案数+递归
我们定义第一代hiho字符串是"hiho". 第N代hiho字符串是由第N-1代hiho字符串变化得到,规则是: h -> hio i -> hi o -> ho ...
- Python 28 选课系统的讲解
1.首先我们要对每一个新的项目有一个明确的思路,脑子是好东西,但是好记性不如烂笔头,所以,要把能想到的都写下来 2.然后就是创建项目的整体结构框架,比如说:conf ( 配置文件 ) .core ( ...
- HDU1043 Eight
题目: 简单介绍一下八数码问题: 在一个3×3的九宫格上,填有1~8八个数字,空余一个位置,例如下图: 1 2 3 4 5 6 7 8 在上图中,由于右下角位置是空的 ...
- Elasticsearch 7.1.1 集群 + 配置身份验证
一.安装Elasticsearch 1.1 环境说明 Centos7.6 Elasticsearch7.1.1 #挂载数据盘 fdisk /dev/vdb n,p,,回车,回车,wq fdisk -l ...
- springboot 的一般配置
import javax.servlet.Filter; import org.springframework.boot.SpringApplication; import org.springfra ...
- 浅谈Websocket、Ajax轮询和长轮询(long polling)
浅谈Websocket.Ajax轮询和长轮询(long p0ll) 最近看到了一些介绍Websocket的文章,觉得挺有用,所以在这里将自己的对其三者的理解记录一下. 1.什么是Websocket W ...
- Spring boot -环境搭建 ,初步接触(1)
1. Eclipse 创建 maven project 项目目录如下: 2. pom.xml 配置文件 <project xmlns="http://maven.apache.or ...
- 金立 M6 (GN8003) 解锁 BootLoader 进入第三方 recovery 刷机 ROOT
首先下载好工具:http://url.cn/5EILbQn 备用连接 :http://pan.baidu.com/s/1c28j7k0 本篇教程教你如何傻瓜式解锁BootLoader并刷入recove ...
- 编码的来历和使用 utf-8 和GB2312比较
经常我们打开外国网站的时候出现乱码,又或者打开很多非英语的外国网站的时候,显示的都是口口口口口的字符, wordpress程序是用的UTF-8,很多cms用的是GB2312. ● 为什么有这么多编码? ...
- 【SQL】结构化查询语言
一:数据查询语言(DQL:Data Query Language): 其语句,也称为“数据检索语句”,用以从表中获得数据,确定数据怎样在应用程序给出.保留字SELECT是DQL(也是所有SQL)用得最 ...