extjs_09_定义自己的页面组件
1.项目截图
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWRhbV93enM=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="">
2.CustomSizePagingToolbar.js
Ext.define("Ext.ux.CustomSizePagingToolbar", {// 定义的名字要和文件的名字大写和小写一样
extend : "Ext.toolbar.Paging",
alias : "widget.custompaging",// 别名
beforSizeText : "每页",
afterSizeText : "条",
getCustomItems : function() {
var me = this;
// 自己定义customComStore
var customComStore = Ext.create("Ext.data.JsonStore", {
fields : [ "customPageSize" ],
data : [ {
customPageSize : "10"
}, {
customPageSize : "20"
}, {
customPageSize : "50"
}, {
customPageSize : "100"
} ]
})
// 自己定义customComboBox
var customComboBox = Ext.create("Ext.form.field.ComboBox", {
itemId : "customComboId",
store : customComStore,
queryMode : "local",
displayField : "customPageSize",
valueField : "customPageSize",
enableKeyEvents : true,// 感应键盘事件
width : 60,
listeners : {
scope : me,// 作用域
select : me.onCustomSelect,
keydown : me.onCustomKeyDown,
blur : me.onCustomBlur
}
});
// - 表示切割线,> 表示右边显示
return [ "-", me.beforSizeText, customComboBox, me.afterSizeText ];
},
onCustomSelect : function(combo, records, eOpts) {// 选择事件触发
var me = this;
me.store.pageSize = records[0].data.customPageSize;
me.store.loadPage(1);// 默认载入第一页
},
onCustomKeyDown : function(field, e, eOpts) {// 按键事件触发
var me = this;
var k = e.getKey();
if (k == e.ENTER) {
e.stopEvent();// 停止其它事件
me.store.pageSize = me.child("#customComboId").getValue();
me.store.loadPage(1);
}
},
onCustomBlur : function(combo, the, eOpts) {// 失去焦点事件
var me = this;
me.child("#customComboId").setValue(me.store.pageSize);
},
// 初始化界面组件
initComponent : function() {
var me = this;
Ext.apply(me, {// 应用、附加
items : me.getCustomItems()
});
me.callParent(arguments);
me.child("#customComboId").setValue(me.store.pageSize);// 初始化赋值
}
})
3.custompaging.jsp
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head> <title>自己定义分页组建</title> <!-- 引入样式,能够把ext-all.css换成ext-all-access.css | ext-all-gray.css改变样式-->
<link rel="stylesheet" type="text/css" href="./extjs4.1/resources/css/ext-all.css">
<!-- 开发模式引入ext-all-debug.js,公布模式引入ext-all.js -->
<script type="text/javascript" src="./extjs4.1/ext-all-debug.js"></script>
<!-- 语言包 -->
<script type="text/javascript" src="./extjs4.1/locale/ext-lang-zh_CN.js"></script>
<!-- 引入自己定义分页 -->
<script type="text/javascript" src="./extjs4.1/ux/CustomSizePagingToolbar.js"></script> <script type="text/javascript">
Ext.onReady(function() {
Ext.QuickTips.init();//高速提示初始化
Ext.Loader.setConfig({
paths : {
"Ext.ux" : "extjs4.1/ux"//文件载入路径(Ext.ux=extjs4.1/ux)
}
}); // 自己定义数据模型
var jsonpModel = Ext.define("jsonpModel", {
extend : "Ext.data.Model",
fields : [ {
name : "userid",
type : "string"
}, {
name : "username",
type : "string"
}, {
name : "dateline",
type : "string"
}, {
name : "title",
type : "string"
} ]
});
// 数据
var myStore = Ext.create("Ext.data.Store", {
model : "jsonpModel",
pageSize : 10,//配置每页显示记录数
proxy : {
type : "jsonp",
url : "http://www.sencha.com/forum/topics-browse-remote.php",
reader : {
totalProperty : "totalCount",
root : "topics"
}
},
// 自己主动载入数据
autoLoad : true
}); // 表格
var myGrid = new Ext.grid.Panel({
columns : [ {
xtype : "rownumberer",
text : "行号",
width : 30
}, {
text : "用户id",
dataIndex : "userid"
}, {
text : "用户姓名",
dataIndex : "username"
}, {
text : "时间线",
dataIndex : "dateline"
}, {
text : "标题",
dataIndex : "title"
} ],
store : myStore,
bbar : Ext.create("Ext.ux.CustomSizePagingToolbar", {// 在表格底部 配置分页
displayInfo : true,
store : myStore
})
}); // 窗体
var window = Ext.create("Ext.window.Window", {
title : "学生成绩表",
width : 600,
height : 400,
items : myGrid,
layout : "fit"
});
window.show();
});
</script> </head> <body>
<br> 自己定义分页组件
</body>
</html>
版权声明:本文博客原创文章,博客,未经同意,不得转载。
extjs_09_定义自己的页面组件的更多相关文章
- css页面组件
页面组件 1 元素的尺寸/边框/背景 1.1 css尺寸相关属性 height 高度 min-height 最小高度 max-height 最大高度 width 宽度 min-width 最小宽度 m ...
- 054——VUE中vue-router之实例讲解定义一下单页面路由
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- HTML5/CSS3 第二章页面组件
页面组件 1 元素的尺寸/边框/背景 1.1 css尺寸相关属性 height 高度 min-height 最小高度 max-height 最大高度 width 宽度 min-width 最小宽度 m ...
- new Vue() 和 export default {}及Vue页面组件和标签组件说明与比较(非常重要)
说明与比较:new Vue() 和 export default {} (1)vue就是一个构造函数 (2)vue标签组件:是HTML标签的扩展https://www.cnblogs.com/w-wa ...
- 基于HBuilderX+UniApp+ThorUI的手机端前端的页面组件化开发经验
现在的很多程序应用,基本上都是需要多端覆盖,因此基于一个Web API的后端接口,来构建多端应用,如微信.H5.APP.WInForm.BS的Web管理端等都是常见的应用.本篇随笔继续分析总结一下项目 ...
- 通用easyui查询页面组件
easyui查询页面组件使用指南 本组件开发需求:信息系统的查询页面基本是包括:搜索区域,列表显示区域,按钮条. 1.录入一个查询语句(如:select * from Strudents),录入列表显 ...
- vue教程3-03 vue组件,定义全局、局部组件,配合模板,动态组件
vue教程3-03 vue组件,定义全局.局部组件,配合模板,动态组件 一.定义一个组件 定义一个组件: 1. 全局组件 var Aaa=Vue.extend({ template:'<h3&g ...
- SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件
SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件. Why? 下拉刷新这样的控件.想必大家用的太多了,比方使用非常多的XListView等. 近期.项目中非常多列表都 ...
- Vue框架——页面组件中使用小组件
小组件在components文件夹中,页面组件在views文件夹中 一.先写小组件的vue,比如text.vue(在template设置模板渲染,style设置样式) <template> ...
随机推荐
- java获取指定地址图片高度宽度简单代码
package com.test; import java.awt.image.BufferedImage; import java.io.IOException; import java.io.In ...
- KMP求字符串最小循环节
证明1: 对于一个字符串S,长度为L,如果由长度为len的字符串s(字符串s的最小循环节是其本身)循环k次构成,那么字符串s就是字符串S的最小循环节 那么字符串有个很重要的性质和KMP挂钩,即 i ...
- veridata实验例(3)验证veridata发现insert操作不会导致同步
veridata实验例(3)验证veridata发现insert操作不会导致同步 续接:<veridata实验举例(2)验证表BONUS与表SALGRADE两节点同步情况>,地址:点击打开 ...
- leetcode dfs Validate Binary Search Tree
Validate Binary Search Tree Total Accepted: 23828 Total Submissions: 91943My Submissions Given a bin ...
- Android研究之手PullToRefresh(ListView GridView 下拉刷新)使用具体解释
群里一哥们今天聊天偶然提到这个git hub上的控件:pull-to-refresh ,有兴趣的看下,样例中的功能极其强大,支持非常多控件.本篇博客具体给大家介绍下ListView和GridVi ...
- 基于lua的网页脚本开发语言cgilua(转)
这里为大家介绍基于lua脚本实现的网页开发语言,cgilua 介绍 cgilua使用Lua是一个用于创建动态网页的服务器端脚本语言.纯LUA脚本和LUA页(LP)的支持,cgilua.Lua脚本是一个 ...
- Ubuntu下搭建ASP.NET 5
在Ubuntu下搭建ASP.NET 5开发环境 0x00 写在前面的废话 年底这段时间实在太忙了,各种事情都凑在这个时候,没时间去学习自己感兴趣的东西,所以博客也好就没写了.最近工作上有个小功能要 ...
- oracle dblink造成远程数据库session过多
现场报网公司数据库连不上,先检查了下数据库processes=1500,session=2200.我认为非常大啊.这个数据库没有几个人用. 查看v$session中的session最多是哪个machi ...
- Java中使用Lua脚本语言(转)
Lua是一个实用的脚本语言,相对于Python来说,比较小巧,但它功能并不逊色,特别是在游戏开发中非常实用(WoW采用的就是Lua作为脚本的).Lua在C\C++的实现我就不多说了,网上随便一搜,到处 ...
- oracle的unique约束
unique约束是唯一性约束,对于需要列类型应用程序会重复出现分歧值.您可以加入一个单独的列unique约束.能够加入多个列unique约束().假设为多个列加入一个unique约束,仅仅须要保证这多 ...