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_定义自己的页面组件的更多相关文章

  1. css页面组件

    页面组件 1 元素的尺寸/边框/背景 1.1 css尺寸相关属性 height 高度 min-height 最小高度 max-height 最大高度 width 宽度 min-width 最小宽度 m ...

  2. 054——VUE中vue-router之实例讲解定义一下单页面路由

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. HTML5/CSS3 第二章页面组件

    页面组件 1 元素的尺寸/边框/背景 1.1 css尺寸相关属性 height 高度 min-height 最小高度 max-height 最大高度 width 宽度 min-width 最小宽度 m ...

  4. new Vue() 和 export default {}及Vue页面组件和标签组件说明与比较(非常重要)

    说明与比较:new Vue() 和 export default {} (1)vue就是一个构造函数 (2)vue标签组件:是HTML标签的扩展https://www.cnblogs.com/w-wa ...

  5. 基于HBuilderX+UniApp+ThorUI的手机端前端的页面组件化开发经验

    现在的很多程序应用,基本上都是需要多端覆盖,因此基于一个Web API的后端接口,来构建多端应用,如微信.H5.APP.WInForm.BS的Web管理端等都是常见的应用.本篇随笔继续分析总结一下项目 ...

  6. 通用easyui查询页面组件

    easyui查询页面组件使用指南 本组件开发需求:信息系统的查询页面基本是包括:搜索区域,列表显示区域,按钮条. 1.录入一个查询语句(如:select * from Strudents),录入列表显 ...

  7. vue教程3-03 vue组件,定义全局、局部组件,配合模板,动态组件

    vue教程3-03 vue组件,定义全局.局部组件,配合模板,动态组件 一.定义一个组件 定义一个组件: 1. 全局组件 var Aaa=Vue.extend({ template:'<h3&g ...

  8. SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件

    SuperSwipeRefreshLayout 一个功能强大的自己定义下拉刷新组件. Why? 下拉刷新这样的控件.想必大家用的太多了,比方使用非常多的XListView等. 近期.项目中非常多列表都 ...

  9. Vue框架——页面组件中使用小组件

    小组件在components文件夹中,页面组件在views文件夹中 一.先写小组件的vue,比如text.vue(在template设置模板渲染,style设置样式) <template> ...

随机推荐

  1. ecshop2.7.3怎么自动清除缓存

    1.在ecs_shop_config表中插入一条数据 进入ECSHOP后台-数据库管理-SQL查询 复制下面SQL,粘贴到里面执行.注意这时是默认表前缀ecs_,如果你的修改过要和你的统一了. INS ...

  2. WPF对于xml的简单操作(上)

    private void button1_Click(object sender, RoutedEventArgs e) { XmlTextWriter writer = new XmlTextWri ...

  3. C语言cgi(1)

    1Columbia Universitycs3157 – Advanced ProgrammingSummer 2014, Lab #2, 60ish pointsJune 9, 2014Follow ...

  4.  paip.android环境搭建与开发事例

    paip.android环境搭建与开发事例 好长时间没有玩AndROID了..以前常常做ANDROID的,今天决定在下载一个要做个时间设置器 作者Attilax ,  EMAIL:1466519819 ...

  5. log4j 日志大小限制 分成30一个 不按日期分日志 按大小分成 按生产日期

    首先说说生成按日期.不解释,大家都懂的,这种方法的缺点是很吃硬盘空间 log4j.rootLogger=INFO,logfile,stdout log4j.logger.java.sql=DEBUG, ...

  6. 3D MAX脚本教程1

    本文转载自http://jiurong995294.blog.163.com/blog/static/195133243201192531546490/ 方便以后须要时候使用 为什么要学习3D MAX ...

  7. WinForm 国际化开发一例

    1.新建一个WinForm程序(在中文版的Windows下),如下,添加1个Button和1个Label 设置Form1的localizable属性为True(Form1的properties里的De ...

  8. Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法)

    Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法) ...

  9. rsync+inotify 实现资源服务器的同步目录下的文件变化时,备份服务器的同步目录更新,以资源服务器为准,去同步其他客户端

    测试环境: 资源服务器(主服务器):192.168.200.95 备份服务器(客户端):192.168.200.89 同步目录:/etc/test 同步时使用的用户名hadoop密码12345 实验目 ...

  10. BeagleBone Black 板第三课:Debian7.5系统安装和远程控制BBB板

    BBB板第三课:Debian7.5系统安装和远程控制BBB板 由于BBB板系统是Debian 7.4.据说使用Debian系统能够实现非常多BBB板的无缝连接.能够更好的学习和控制BBB板,所以就决定 ...