设为首页 收藏本站
查看: 597|回复: 0

[经验分享] 11级_Java_曹建波 04.07 jQuery easyUI +struts2+hibernate+oracle 实现 admin用户的分页操作

[复制链接]

尚未签到

发表于 2016-9-2 12:04:27 | 显示全部楼层 |阅读模式
  jQueryeasyUI+struts2+hibernate+oracle
  实现admin用户的分页操作
  
  
  
  
  核心代码
  
  Init.js
  $(document).ready(function(){
  //获取所有的a元素
  var$as=$("li>a");
  //获取id=tabs的元素
  var$tt=$("#tt");
  
  //注册点击事件
  $as.bind("click",function(){
  vartext=$(this).text();
  varurl=this.href;
  
  //获取添加的text根据获取id=tt面板中是否包含含有text标题的面板
  varcurtab=$("#tt").tabs("getTab",text);
  
  alert(curtab);
  
  if(curtab){
  //jQuery对象
  variframe=$(curtab.panel('options').content);
  //根据属性名称获取该属性值
  varsrc1=iframe.attr("src");
  $("#tt").tabs("update",{
  tab:curtab,
  options:{
  content:createFrame(src1)
  }
  });
  }else{
  $("#tt").tabs('add',{
  title:text,
  closable:true,
  content:createFrame(url),//创建面板内容
  tools:[{
  iconCls:'icon-mini-refresh',
  handler:function(){
  alert('refresh');
  }
  }]
  });
  }
  
  returnfalse;
  });
  
  });
  
  //创建面板
  functioncreateFrame(url){
  varsrc='<iframescrolling="auto"frameborder="0"src="'+url+'"style="width:100%;height:100%;"></iframe>';
  returnsrc;
  }
  
  Adminlist.js
  $(document).ready(function(){
  
  $('#adminlist').datagrid({
  url:'./csdn/AdminAction_query.action?time='+newDate().getTime(),
  loadMsg:"数据正在加载……",
  pageNumber:1,//初始化起始的页码
  pageSize:10,//每页显示的数据量(测试改变不发生变化)
  pageList:[10,15,20],//每页显示的数据量可选项
  sortName:'aid',//定义排列的名称
  sortOrder:'asc',//定义排列的方式asc
  striped:true,//是否实现隔行变色
  fitColumns:true,//是否自动设置列的宽度
  singleSelect:false,
  idField:'aid',//标识字段
  frozenColumns:[[{
  field:'ck',
  checkbox:true
  },{
  title:'序号',
  field:'aid',
  width:50,
  sortable:true
  }]],
  columns:[[{
  field:'aname',
  title:'用户名',
  width:100
  },{
  field:'apass',
  title:'密码',
  width:100,
  align:'left',
  editor:{
  type:'text'
  }
  }]],
  pagination:true,
  shownumbers:false,
  toolbar:[{
  iconCls:"icon-add",
  text:"添加",
  handler:function(){
  $("#adminlist").dialog("open");
  }
  },{
  iconCls:"icon-remove",
  text:"删除",
  handler:function(){
  vardatas=$('#adminlist').datagrid('getSelections');
  
  if(datas.length<=0){
  showMsg("提示","没有选中数据,不能执行删除!");
  return;
  }
  
  
  $(datas).each(function(index){
  varrowIndex=$('#adminlist').datagrid('getRowIndex',this);
  $('#adminlist').datagrid('deleteRow',rowIndex);
  ids=this.aid;
  });
  
  $.post("./csdn/AdminAction_deleteById.action",{
  id:ids
  },function(){
  showMsg("成功","删除成功!");
  $('#adminlist').datagrid('reload');
  });
  }
  },{
  iconCls:"icon-edit",
  text:"修改",
  handler:function(){
  alert("修改");
  }
  },{
  iconCls:"icon-save",
  text:"保存",
  handler:function(){
  alert("保存");
  }
  }]
  });
  varpagination=$('#adminlist').datagrid('getPager');
  //设置分页属性
  pagination.pagination({
  beforePageText:"",
  afterPageText:"页共{pages}",
  displayMsg:"从第{from}条到第{to}条共{total}"
  });
  $("#adminlist").dialog({
  title:"添加管理员",
  modal:true,
  width:300,
  height:350,
  closed:true,
  onBeforeOpen:function(){
  $("#parentType").combotree("reload");
  $("#add").form("clear");
  }
  });
  
  $("#add").form({
  url:'../../csdn/addGoodsType.action',
  onSubmit:function(){
  if(!$("#aname").validatebox("isValid")||!$("#apass").validatebox("isValid")){
  returnfalse;
  }
  },
  success:function(data){
  $("#adminlist").dialog("close");
  $('#adminlist').datagrid("reload");
  }
  });
  $('#adminlist').datagrid({
  onDblClickRow:function(rowIndex,rowData){
  //alert(rowIndex+"------"+rowData.aname);
  $('#adminlist').datagrid("beginEdit",rowIndex);
  }
  });
  });
  functionshowMsg(title,msg){
  $.messager.show({
  title:title,
  showType:"slide",
  msg:msg,
  timeout:1000
  });
  }
  
  
  
  Index.jsp
  <%@pagelanguage="java"import="java.util.*"pageEncoding="UTF-8"%>
  <%
  Stringpath=request.getContextPath();
  StringbasePath=request.getScheme()+"://"
  +request.getServerName()+":"+request.getServerPort()
  +path+"/";
  %>
  
  <!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
  <html>
  <head>
  <basehref="<%=basePath%>">
  
  <title>MyJSP'index.jsp'startingpage</title>
  
  <metahttp-equiv="pragma"content="no-cache">
  <metahttp-equiv="cache-control"content="no-cache">
  <metahttp-equiv="expires"content="0">
  <metahttp-equiv="keywords"content="keyword1,keyword2,keyword3">
  <metahttp-equiv="description"content="Thisismypage">
  <!--
  <linkrel="stylesheet"type="text/css"href="styles.css">
  -->
  
  <linkrel="stylesheet"type="text/css"
  href="${pageContext.request.contextPath}/styles/easyui/themes/default/easyui.css">
  <linkrel="stylesheet"type="text/css"
  href="${pageContext.request.contextPath}/styles/easyui/themes/icon.css">
  <linkrel="stylesheet"type="text/css"
  href="${pageContext.request.contextPath}/styles/manager/init.css">
  <scripttype="text/javascript"
  src="${pageContext.request.contextPath}/scripts/jquery-1.8.0.min.js"></script>
  <scripttype="text/javascript"
  src="${pageContext.request.contextPath}/scripts/jquery.easyui.min.js"></script>
  <scripttype="text/javascript"
  src="${pageContext.request.contextPath}/scripts/manager/init.js"></script>
  
  </head>
  
  <body>
  <divid="box"class="easyui-layout">
  <!--north开始-->
  <divdata-options="region:'north',title:'NorthTitle',split:true"
  style="height:100px;"></div>
  <!--north结束-->
  
  
  <%--<div
  data-options="region:'east',iconCls:'icon-reload',title:'East',split:true"
  style="width:100px;"></div>
  
  --%>
  <!--west开始-->
  <divdata-options="region:'west',title:'导航菜单',split:true"
  style="width:200px;">
  <divid="nav"class="easyui-accordion"
  data-options="fit:true,border:false"
  style="padding-right:5px;padding-left:5px;">
  
  <divtitle="管理员管理"data-options="iconCls:'icon-save'">
  <ul>
  <li><a
  href="${pageContext.request.contextPath}/backstage/admin/admin_list.jsp">管理员列表</a>
  </li>
  </ul>
  </div>
  
  <divtitle="会员管理">
  <ul>
  
  <li><ahref="#">会员列表</a></li>
  </ul>
  
  </div>
  
  
  <divtitle="商品类别管理"data-options="iconCls:'icon-reload'"
  style="padding:10px;">
  <ul>
  <li><ahref="${pageContext.request.contextPath}/backstage/goodstype_list.jsp">商品类别列表</a></li>
  </ul>
  
  </div>
  
  <divtitle="商品管理"data-options="iconCls:'icon-reload'"
  style="padding:10px;">
  <ul>
  <li><ahref="#">商品列表</a></li>
  </ul>
  
  </div>
  </div>
  </div>
  <!--west结束-->
  
  <!--center开始-->
  <divdata-options="region:'center'"style="">
  <divid="tt"class="easyui-tabs"data-options="fit:true">
  <divtitle="后台操作的界面"style="padding:20px;">后台操作界面的说明</div>
  </div>
  </div>
  <!--center结束-->
  
  
  
  <!--south开始-->
  <divdata-options="region:'south',split:true"
  style="height:25px;padding:5px;background:#D2E0F2;">
  <divalign="center">版权归河北软件职业技术学院@河软CSDN乐知学院所有2013-2020</div>
  </div>
  <!--south结束-->
  </div>
  
  </body>
  </html>
  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.iyunv.com/thread-266724-1-1.html 上篇帖子: 求指点rman配置冗余的一个语法问题 下篇帖子: Oracle中通过:触发器,存储过程,Function调用实现解析Clob字段类型中存储的xml字符串
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表