- 浏览: 234282 次
- 性别:
- 来自: 广州
文章分类
最新评论
-
q459997705:
写的很好,对我很有用
java 连接paradox数据库的几种方式 -
raisun_1988:
还不会用啊
扩展GridPanel,附带分页选中状态,实现快速构建一个功能齐全的Grid -
海阔天空shen:
貌似不行吧 一直loading
查看ext的api文档 -
fxn19870827:
好像是不行啊
jsp解决图片缓存问题 -
songs_0319:
没有用 ,在firefox里面还是乱码
设置EXT提交数据的编码
使用简单的配置就可以实现 store, columns, selModel , pagingToolbar ,
最重要的一点是实现分页时可以保持前一页的选中状态,
但是要遵守其中的一些规定,至于哪些规定呢,看下面的代码就知道啦!
代码如下:
最重要的一点是实现分页时可以保持前一页的选中状态,
但是要遵守其中的一些规定,至于哪些规定呢,看下面的代码就知道啦!
代码如下:
/* * @class Ext.ux.grid.CollectGrid * @version: 1.0 * @author: chengbao_zhu * * Example : Ext.onReady(function(){ var CM_JR_Record = [ { dataIndex:"", //the ColumnModel options alse the JsonReader mapping (required) header:"", //the ColumnModel options (required) visiable: false, //my expands option to show the header or not (options) type: date, //the type of this data (options) ...another options of ColumnModel },{ dataIndex : '', header : "", width : 130 }]; var myGrid = new Ext.ux.grid.CollectGrid({ url : 'MyJsp.jsp', // the store load url (required) CM_JR_Record: CM_JR_Record, //.....(required) rowNumber:true, //true to add a Ext.grid.RowNumberer,defalut(true) checkBox:true, //true to add a Ext.grid.CheckBoxSelectionModel,default(true) pagingBar:true, //true to add a Ext.PagingToolBar,default(true) pagingConfig:objcet, //config pagingToolBar if pagingBar is true keepSelectedOnPaging: true, //true to FireEvent when you paging to keep the state of record selected recordIds : new Array() , // store seleced ids when keepSelectedOnPaging is true idColName :'stat_id', //the id column name ...another width : 700, height: 600, title : 'This is My Grid' , renderTo: 'my_grid' }); myGrid.store.load({params:{start:0,limit:myGrid.pagingConfig.pageSize}}); //myUxGrid.render(); myGrid.on('rowclick',function(grid,rowIndex,e){ alert(grid.getStore().getAt(rowIndex).data['stat_id']); } ); } ); */ Ext.namespace('Ext.ux.grid'); Ext.ux.grid.CollectGrid = Ext.extend(Ext.grid.GridPanel,{ /* * true to keep the records selected when you paging * @default(false) * @type: boolean */ keepSelectedOnPaging: false, /* * the array to store the record id * @type: array */ recordIds:new Array(), /* * set your id Column Name * @default : this.CM_JR_Record[0].dataIndex */ idColName:'', /* * set this.store.load url; * @type: string */ url: '', /* * show the rowNumber or not * @type: boolean * @default: true */ rowNumber : true, /* * set the grid sm,if checkBoxSelection=true,sm=CheckBoxSelectionModel * else sm=RowSelectionModel,default to true; * @type: boolean */ checkBox: true, /* * set the grid cm array; * set the JsonReader record; * * format: [{name:'',header:'',visiable:'',...another cm options},{}], * @name=dataIndex * @visiable: set this record to the cm(grid header) default(true) * @type: array (records) */ CM_JR_Record: null, /* * true to add a bottom paging bar * @defalut: true * @type: boolean */ pagingBar: true, /* * config paging bar if pagingBar set true * @type: object * @default: {pageSize: 20,store: this.store,displayInfo: true, * displayMsg: '当前记录数: {0} - {1} 总记录数: {2}', * emptyMsg: '<b>0</b> 条记录'} */ pagingConfig:{ pageSize: 20, //store: this.store, displayInfo: true, displayMsg: '当前记录数: {0} - {1} 总记录数: {2}', emptyMsg: '<b>0</b> 条记录' }, viewConfig:{ forceFit: true }, //private initComponent: function(){ if(this.CM_JR_Record){ this.init_SM_CM_DS(); } if(this.pagingBar){ this.init_PagingBar(); } if(this.keepSelectedOnPaging){ this.init_OnPaging(); } Ext.ux.grid.CollectGrid.superclass.initComponent.call(this); }, /* * init the grid use the config options * @return: void * @params: none */ init_SM_CM_DS: function(){ var gCm = new Array(); var gRecord = new Array(); if(this.rowNumber){ gCm[gCm.length]=new Ext.grid.RowNumberer(); } if(this.checkBox){ var sm = new Ext.grid.CheckboxSelectionModel(); gCm[gCm.length] = sm; this.selModel = sm; } for(var i=0;i<this.CM_JR_Record.length;i++) { var g = this.CM_JR_Record[i]; if(g.visiable || g.visiable=='undefined' || g.visiable==null){ gCm[gCm.length] = g; } gRecord[gRecord.length]={ name: g.dataIndex, type: g.type || 'string' } } //create grid columnModel this.cm = new Ext.grid.ColumnModel(gCm); this.cm.defaultSortable = true; //create a jsonStore this.store = new Ext.data.Store({ proxy: new Ext.data.HttpProxy({ url: this.url, method: 'post' }), reader:new Ext.data.JsonReader({ totalProperty: 'totalProperty', root: 'root' }, Ext.data.Record.create(gRecord) ) }); this.pagingConfig.store = this.store; if(this.pagingBar){ this.store.load({params:{start:0,limit:this.pagingConfig.pageSize}}); }else{ this.store.load(); } }, /* * 创建并初始化paging bar */ init_PagingBar: function(){ var bbar = new Ext.PagingToolbar(this.pagingConfig); this.bbar = bbar; }, init_OnPaging: function(){ this.idColName = this.CM_JR_Record[0].dataIndex ;//默认第一列为ID列 this.selModel.on('rowdeselect',function(selMdl,rowIndex,rec ){ for(var i=0;i<this.recordIds.length;i++) { if(rec.data[this.idColName] == this.recordIds[i]){ this.recordIds.splice(i,1); return; } } },this); this.selModel.on('rowselect',function(selMdl,rowIndex,rec){ if(this.hasElement(this.recordIds)){ for(var i=0;i<this.recordIds.length;i++){ if(rec.data[this.idColName] == this.recordIds[i]){ return; } } } this.recordIds.unshift(rec.data[this.idColName]); },this); this.store.on('load',function(st,recs){ if(this.hasElement(this.recordIds)){ st.each(function(rec){ Ext.each(this.recordIds,function(item,index,allItems){ if(rec.data[this.idColName] == item){ this.selModel.selectRecords([rec],true); return false; } },this); },this); } },this); }, hasElement : function(recIds){ if(recIds.length > 0) return true; else return false; } } )
- cgrid.rar (2.3 KB)
- 描述: 源代码js文件
- 下载次数: 242
发表评论
-
EXT CHANGELOG
2010-04-02 10:29 9913.2http://www.extjs.com/produc ... -
给Ext.Toolbar加上remove方法以移除子组件
2010-02-08 10:02 2643在用Ext.Toolbar的时候,发现竟然没有remove方法 ... -
ext panel屏蔽右键菜单
2010-01-11 14:46 1997panel.on('render',function(){ ... -
extjs htmleditor readOnly无效解决方法
2010-01-07 13:03 2491Ext 里的Ext.form.HtmlEditor里readO ... -
ext TabPanel相关
2009-04-24 12:11 2073在使用Ext.TabPanel时,经常会用到tabchang ... -
extjs GridPanel 相关
2009-04-16 16:41 1989var hmenu = this.grid.getView() ... -
extjs store 相关
2009-04-16 16:39 1197Method filterBy(fn,scope)过虑记录时 ... -
遍历ext form表单的递归方法
2009-04-10 10:54 2105function eachItem(item,inde ... -
javascript 闭包
2009-03-26 20:40 866elf8848 写道 function outer ... -
extjs - 树
2009-03-12 17:55 1787<1>重新load单一树节点(node) t ... -
查看ext的api文档
2008-12-29 22:36 2306找到这个localXHR.js(附件里有这个文件)复制到doc ... -
设置EXT提交数据的编码
2008-10-27 10:35 1312对于提交中出现的乱码,在Ext中可以修改Request Hea ... -
扩展combobox的下拉Grid
2008-09-17 12:45 3839/** * 下拉ComboBoxGrid * ... -
Ext Js 给window或panel加上热键
2008-08-21 14:25 2426如题,代码如下: var OverTimeForm = n ... -
ext 图片预览事件触发以及IE7下预览图片
2008-08-21 14:11 3001首先在FormPanel里添加图片预览区以及图片选择组件 ... -
下拉树ComboBoxTree
2008-08-21 13:44 8133在网上搜了两棵下拉树,均有一些小问题,用不了,于是自己参考它们 ... -
Ext.Panel API翻译
2008-07-22 11:17 2912Ext.Panel API翻译 引用网 ... -
ExtJs 的一些技巧与问题
2008-07-15 13:36 3798[color=white] [list=1] 修改 ... -
ExtJs 委托与回调(createDelegate && createCallback)
2008-07-15 12:44 2021author=Ext Community(译者:[http:/ ... -
ExtJs 上传控件change事件触发解决方法
2008-06-06 14:18 9385在 Ext 中,上传控件的ch ...
相关推荐
在使用表格的分页功能时,我们把该控件的start与limits参数与Hibernate的分页功能影射,从页实现了动态的分页效果;而TreePanel的更新也是一个比较常见的问题,当我们点击测试按钮时,TreePanel会请求远程服务器的...
对于GridPanel中拖动选中行排序的实现,网上有不少ExtJs实现的例子,但是没有找到使用Ext.net实现的,正好最近有个需求要使用,干脆来写一个。 DEMO功能说明: 1、拖动GridPanel选中行到新位置排序。 2、在拖动结束...
扩展的GridPanel,让其分页后保持选择状态
Ext GridPanel 中实现加链接操作 Ext GridPanel 中实现加链接操作 Ext GridPanel 中实现加链接操作
针对Gridpanel多表头的扩展,适用于2.2的ext版本,3以上的没有测试过,有兴趣的可以自己研究研究。
Ext.grid.GridPanel属性祥解, 表格部门的详解,通俗易懂,适合初学人员,以及想对GridPanel有个精析认识的Web开发人员
Ext.grid.GridPanel 删除线 放到example文件夹下运行
Ext.grid.GridPanel有一个重大缺陷,就是单元格的内容不能选中,没法选中就没法复制,给用户带来很多不便,下面是从网上搜到的解决方案。
ExtJs GridPanel双击事件获得双击的行,双击行可以选中前面的checkbox,并获得行号
EXT实例GridPanel. 实现简单的。
改变gridpanel的行颜色,以及gridpanel 的表格变色
EXT GridPanel获取某一单元格的值
NULL 博文链接:https://wv1124.iteye.com/blog/741559
Ext的gridpanel控件二次加载时丢失解决方案
Extnet GridPanel 增行 删行 弹出窗体 页面传值
gridpanel的使用,挺好的啊 gridpanel的使用,挺好的啊 gridpanel的使用,挺好的啊
NULL 博文链接:https://redboy5711.iteye.com/blog/259913