-
jquery easy ui 查询问题5
后台java://接受参数page和rows String page =request.getParameter("page");//每页显示的记录数 String rows = request.getParameter("rows");//当前第几页 String stu_id = request.getParameter("stu_id"); String stu_name = request.getParameter("stu_name"); System.out.println(stu_id); System.out.println(stu_name); //当前页 int intPage = Integer.parseInt((page == null || page == "0") ? "1":page); //每页显示条数 int number = Integer.parseInt((rows == null || rows == "0") ? "10":rows); //每页的开始记录 第一页为1 第二页为number +1 int start = (intPage-1)*number; PrintWriter out = response.getWriter(); StudentDAO sd = new StudentDAOImpl(); //得到总共有多少条数据 int totalCount = sd.getCount(stu_id,stu_name); ArrayList<Student> students= sd.getStudents(start,number,stu_id,stu_name); Map<String, Object> jsonMap = new HashMap<String, Object>();//定义map jsonMap.put("total",totalCount);//total键 存放总记录数,必须的 jsonMap.put("rows", students);//rows键 存放每页记录 list JSONObject result = JSONObject.fromObject(jsonMap);//格式化result 一定要是JSONObject System.out.println(result); out.print(result.toString()); out.flush(); out.close();
js:<script type="text/javascript"> $(function(){ $('#dg').datagrid('getPager').pagination({ displayMsg:'当前显示从{from}到{to},共{total}记录', onBeforeRefresh:function(pageNumber, pageSize){ $(this).pagination('loading'); $(this).pagination('loaded'); } }); }); </script> </head> <body> <table id="dg" title="My Users" class="easyui-datagrid" style="width:700px;height:400px" url="test" pagination="true" toolbar="#toolbar" rownumbers="true" fitColumns="true" singleSelect="true"> <thead> <tr> <th field="id" width="50">id</th> <th field="stu_id" width="50">stu_id</th> <th field="stu_name" width="50">stu_name</th> <th field="stu_password" width="50">stu_password</th> <th field="stu_yuanxi" width="50">stu_yuanxi</th> <th field="stu_phone" width="50">stu_phone</th> <th field="stu_qq" width="50">stu_qq</th> <th field="stu_sex" width="50">stu_sex</th> <th field="stu_age" width="50">stu_age</th> </tr> </thead> </table> <div id="toolbar"> <div> <span>stu_id:</span> <input id="stu_id" style="line-height:26px;border:1px solid #ccc"> <span>stu_name:</span> <input id="stu_name" style="line-height:26px;border:1px solid #ccc"> <a href="#" class="easyui-linkbutton" plain="true" onclick="doSearch()">Search</a> </div> <div> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a> </div> </div> <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px" closed="true" buttons="#dlg-buttons"> <div class="ftitle">User Information</div> <form id="fm" method="post" novalidate> <div class="fitem"> <label>stu_id:</label> <input name="stu_id" class="easyui-validatebox" required="true"> </div> <div class="fitem"> <label>stu_name:</label> <input name="stu_name" class="easyui-validatebox" required="true"> </div> <div class="fitem"> <label>stu_password:</label> <input name="stu_password"> </div> <div class="fitem"> <label>stu_yuanxi:</label> <!-- validType="email" --> <input name="stu_yuanxi" class="easyui-validatebox" > </div> <div class="fitem"> <label>stu_phone:</label> <input name="stu_phone" class="easyui-validatebox" required="true"> </div> <div class="fitem"> <label>stu_qq:</label> <input name="stu_qq" class="easyui-validatebox" required="true"> </div> <div class="fitem"> <label>stu_sex:</label> <input name="stu_sex" class="easyui-validatebox" required="true"> </div> <div class="fitem"> <label>stu_age:</label> <input name="stu_age" class="easyui-validatebox" required="true"> </div> </form> </div> <div id="dlg-buttons"> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveUser()">Save</a> <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">Cancel</a> </div> <script type="text/javascript"> var url; function newUser(){ $('#dlg').dialog('open').dialog('setTitle','New User'); $('#fm').form('clear'); url = 'add'; } function editUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $('#dlg').dialog('open').dialog('setTitle','Edit User'); $('#fm').form('load',row); url = 'edit?id='+row.id; } } function saveUser(){ $('#fm').form('submit',{ url: url, onSubmit: function(){ return $(this).form('validate'); }, success: function(result){ var result = eval('('+result+')'); if (result.success){ $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } else { $.messager.show({ title: 'Error', msg: result.msg }); } } }); } function destroyUser(){ var row = $('#dg').datagrid('getSelected'); if (row){ $.messager.confirm('Confirm','Are you sure you want to remove this user?',function(r){ if (r){ $.post('destroy',{id:row.id},function(result){ if (result.success){ $('#dg').datagrid('reload'); // reload the user data } else { $.messager.show({ // show error message title: 'Error', msg: result.msg }); } },'json'); } }); } } function doSearch(){ $('#dg').datagrid('load',{ stu_id: $('#stu_id').val(), stu_name: $('#stu_name').val(), }); } </script>
前台怎么传值过去,就是说 function doSearch(){
$('#dg').datagrid('load',{
stu_id: $('#stu_id').val(),
stu_name: $('#stu_name').val(),
});
}
这块怎么写url,怎么把值传到后台2013年3月25日 11:49
3个答案 按时间排序 按投票排序
-
采纳的答案
你完全可以使用同一个url查询的,只是第一次传过去的参数为0,查询时传过去的参数不为0而已。然后在service层拼接sql调用dao层就可以了,不知道我说的你能否明白
2013年3月26日 09:08
-
$('#list').datagrid('options').url = '../../Ashx/News/News_Comment.ashx?func=GetList';
$('#list').datagrid("reload");2013年3月25日 18:19
-
定义 datagrid 时设置了URL,在调用 load 方法不需要传URL,你最后写的doSearch方法中的调用就是正确的参数传递方法。
2013年3月25日 12:38
相关推荐
jquery easy-ui的整体文件包,包括树,表单,表格等等,有demo,可以看相关demo后自己导入到项目用。
jquery easy ui 中文帮助
jquery 和 jquery easy UI
jquery easy ui 离线API文档 离线显示,还有各种css值得借鉴
jquery Easy UI教程,很详细,很实用
本资源是本人将SpringMVC + jQuery easy ui整合的CRUD demo,后台核心是spring注解实现的(通过jsbcTemplate连接数据库),前台有基本的jsp和easy ui 两种展现方式,数据库使用oracle,可以通过更改配置文件和驱动jar...
jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面。开发者不需要编写复杂的javascript,也不需要对css样式有深入的了解,开发者需要了解...
这两个模块是非常适合JQuery初学者学习的,我就是照着这两个资源学习的 非常好,我上传就是收藏一下。
博客配套源代码,包含jQuery Easy UI 的几个基础组件的代码示例。
包括jQuery的chm格式说明文档,demo压缩包。jQuery easy-ui的chm格式说明文档。
JQuery Easy UI 增删改查 包含SQL 使用JDBC+Servlet做的示例
jquery easy ui chm说明文档,api
jquery easy ui 增改删 表格
Jquery Easy UI 1.2.6实例代码
本资源主要是教你快速的掌握jquery easy ui 的使用,让你一目了然,让你完全的理解和掌握它,让你完全有信心的告诉自己,这东西我懂了。
通过网站整理的Jquery easy ui 中文帮助手册,像书籍一样建立了层次目录,送给需要的朋友吧。
jquery easy ui edatagrid 动态编辑表格 下拉框 联动 ,支持增加,编辑,删除行,日期狂,下拉框联动显示数据,测试ok
jquery easy UI+spring3.0+struts2.1.8.1+hibernate3.5整合的CRM包括所有Jar包.
jquery easy ui Demo 框架
JQuery Easy UI源码