extjs4 searchField的使用方法 及 remodeFiter 未定义问题的解决
来源:互联网 发布:淘宝店hm正品代购pbee 编辑:程序博客网 时间:2024/06/07 11:20
先来看看效果吧,有点不好的地方就是只能由一个查询参数,不过有需求的话可以自己另设一个from表单来装查询参数
Js部分
1、在使用searchField的地方先设置这个插件的路径
Ext.Loader.setPath('Ext.ux', 'extjs/examples/ux');Ext.define('yang.view.sysManage.UserList', {extend : 'Ext.grid.Panel',alias : 'widget.userList',id : 'userList',title : '用户管理',
2、创建一个searchField对象,在yang.view.sysManage.UserList初始化方法里
var searchField = Ext.create('Ext.ux.form.SearchField', {store : userListStore, //这个store和这个grid panel是同一个store。width : 205,emptyText : '请输入要查找的 username ......'});
然后再toolbar上添加一个这个item
3、在userListStore设置一下remoteFilter 及查询的参数,一下是store的全部源码,查询的关键部分加黑了
Ext.define('yang.store.sysManage.UserListStore', {extend : 'Ext.data.Store',model : 'yang.model.sysManage.UserListModel',pageSize : 5,autoLoad : true,remoteFilter : true,proxy : {type : 'ajax',url : adminFolder + '/listUser.do', // 提交的urlactionMethods : {read : 'POST' // 提交的方式是 POST方式},filterParam : 'name',reader : {type : 'json', // 读到的数据格式是json格式root : 'list', // 数据的根名是 resultListtotalProperty : 'totalCount' // 总记录数的根名是 totalCount}},sorters : [{property : 'id',direction : 'asc'}]});
然后是后台源码,应为列表和查询都在的同一个store了,所以后台需要判断后发查找数据库
@RequestMapping(value = "/listUser.do", method = RequestMethod.POST)@ResponseBodypublic String listUser(@RequestParam(value = "start") Integer offset,@RequestParam(value = "limit") Integer pageSize,@RequestParam(value = "name", required = false) String name) {if (offset == null) {offset = 1;}if (pageSize == null) {pageSize = 5;}String hql = null;PageUtil<User> userPage = null;System.out.println("name=" + name);if (name == null) {hql = "from User";userPage = this.userService.getPageData(hql, offset, pageSize);} else {hql = "from User u where u.name=?";userPage = this.userService.getPageData(hql, offset, pageSize, name);}JSONObject jsonObject = JSONObject.fromObject(userPage);return jsonObject.toString();}
常见问题:
1、出现 substring 错误是因为未引入该插件,只需在该文件引入一下
Ext.Loader.setPath('Ext.ux', 'extjs/examples/ux');2、出现 remoteFilter 错误是因为这个插件使用的store里面的remoteFilter默认是false,需要设置成true,同时在proxy里面添加 filterParam,这个参数后台接受查询的参数。
- extjs4 searchField的使用方法 及 remodeFiter 未定义问题的解决
- Extjs4---Grid的搜索控件SearchField乱码问题
- Extjs 解决MVC中 Ext.ux.SearchField 的问题
- Ext.app.SearchField 与分页参数limit 的问题
- EXTJS4.1我需要解决的问题
- smarty作为view时使用Zend_Form出现方法未定义的问题原因及解决
- WebForm_PostBackOptions未定义的问题
- WebForm_PostBackOptions未定义的问题
- ajaxpro未定义的问题
- sys未定义的问题
- 问题“CString是未定义的标识符”的解决
- asp.net ajax 错误:"sys"未定义问题 解决的方法
- 编译Opal时出现大量未定义符号问题的解决
- [已经解决] sys未定义错误的问题所在!
- 解决my97datepicker在ie6下报$lang未定义的问题
- Ubuntu下math库函数编译时未定义问题的解决
- 解决在IE下“JSON”未定义的问题
- 完美解决IE9浏览器出现的对象未定义问题
- 我的美国CS面试经验分享
- android整合--progressbar
- 无刷新上传文件的三种方式。
- 字符串输入(带空格)
- 一口一口吃掉Hibernate(四)——多对一单向关联映射
- extjs4 searchField的使用方法 及 remodeFiter 未定义问题的解决
- 体验下Xcode5与ios7
- Swing的dialog.addIconToTray();方法可以生成系统托盘
- linux(redhat)下文件结构概述
- Asp.net MVC 3 开发一个简单的企业网站系统
- Spring配置文件总结
- linux常用指令
- Mjpeg-streamer源码学习笔记-Main-get_long(一)
- c++ 指针容器