关于Extjs翻页问题解决
来源:互联网 发布:php class 魔术方法 编辑:程序博客网 时间:2024/05/17 21:54
首先,在前台JS页面注意点:
store 文件设置pageSize,total计数属性和baseParams
detailStore = Ext.extend(Ext.data.JsonStore, { constructor: function(cfg) { cfg = cfg || {}; detailStore.superclass.constructor.call(this, Ext.apply({ autoSave: false, autoLoad: false, url: '/myProject/mySearch.do', root: 'root', pruneModifiedRecords: true, storeId: 'detailStore', fields: [ { name: 'ord', mapping: 'ord' }, { name: 'line', mapping: 'line' { name: 'ordqty', mapping: 'ordqty' } ], pageSize: 30, totalProperty: 'totalCount', baseParams : {start : 0,limit : 30} }, cfg)); }});new detailStore();
tbar: { xtype: 'toolbar', items: [ { xtype: 'button', text: 'Search', width: 100, id: 'btn_search' } ] }, bbar: { xtype: 'paging', store: 'detailStore', pageSize: 30, displayInfo: true }
Search时添加监听方法
Ext.getCmp('btn_search').on('click', this.onClickSearch);
onClickSearch: function (t, e){ if(Ext.getCmp('search-form').getForm().isValid()){ var lm = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."}); lm.show(); var form = Ext.getCmp("search-form").getForm(); var gStore = Ext.getCmp('my-grid').store; gStore.setBaseParam("ord",form.findField("pord").getValue()); //在BaseParam设置查询参数为翻页作准备 gStore.setBaseParam("line",form.findField("pline").getValue()); Ext.Ajax.request({ url:'<span style="font-family: Arial, Helvetica, sans-serif;">/myProject/mySearch.do</span><span style="font-family: Arial, Helvetica, sans-serif;">',</span> timeout:'300000', params: { ord : form.findField("pord").getValue(), line : form.findField("pline").getValue() }, success:function (reponseText,opt){ var jstore = Ext.decode(reponseText.responseText); if (null != jstore && "" != jstore) { var grid = Ext.getCmp('my-grid'); grid.getStore().loadData(jstore); } lm.hide(); }, failure:function (reponseText,opt){ lm.hide(); Ext.Msg.alert('Error', 'Loading failure'); } });// end Ext.Ajax.request}}// end onClickSearch
</pre><p></p><pre>后台Java部分:计算Total总数且取Start开始的30条记录
JSONArray jsonArray = null;int totalCount = bomService.countBomQryDetail(b); //b是查询的Bean条件,此处略,该方法得到TotalCount//page parametersint start = parseInteger((String) arg0.getParameter("start"));int limit = parseInteger((String) arg0.getParameter("limit"));if (limit == 0) limit = 30;//从start取得30条记录List<MyBean> list = bomService.searchDetail(b, start, limit);jsonArray = JSONArray.fromObject(list);arg1.setCharacterEncoding("UTF-8");arg1.setContentType("text/html");arg1.getWriter().print("{totalCount:'" + totalCount + "', root:" + jsonArray + "}"); //返回数据arg1.getWriter().flush();
1 0
- 关于Extjs翻页问题解决
- 关于ExtJs中,下拉列表问题解决
- 关于Myeclipse导入ExtJS出错的问题解决:
- EXTJS 翻页全精通
- ExtJS翻页丢失参数
- extjs翻页控件
- dataTables翻页重叠问题解决
- Extjs 4.0 查询翻页问题
- Extjs 关于文件上传file 框 可输入问题解决
- ExtJs关于grid高度自适应浏览器的问题解决办法
- ExtJs关于grid高度自适应浏览器的问题解决办法
- 关于翻页的问题
- 关于查询和 翻页
- ExtJs界面中文问题解决
- extjs实现自动翻页的功能
- Extjs grig 翻页 勾选记录问题
- 关于extjs
- Ecside checkbox 翻页后保存状态问题解决
- 第10-11周项目:继承与派生
- RGB颜色表
- WindowManager.LayoutParams.type属性
- TCP为什么需要3次握手与4次挥手
- hdu1005 Number Sequence
- 关于Extjs翻页问题解决
- Hibernate中的即时加载
- BeanNameAware接口和BeanFactoryAware接口
- nohup
- 关于JDialog中添加组件无法显示的问题
- Linux下Tomcat的启动、关闭、杀死进程
- Failure [INSTALL_FAILED_UPDATE_INCOMPATIBLE]解决办法
- TcpFlow(1.4.6 C++版本)源代码分析之以太网数据包处理,ip数据包处理
- 面试题8:旋转数组的最小数字