今天来了,不能懒,该写就写;
1.既然是要用jQuery的JS 。那就要放入项目中
2.使用方式jsp+js:
3.调用后台
$(function() { $("#flexgrid").flexigrid({ url : webroot+'sand/messageCodeImportAction!getPagedCityList.action', dataType : 'json', colModel : [ { display : 'ID', name : 'id', width : 80,// 得加上 要不IE报错 sortable : true, hide : true, align : 'center' }, { display : '城市名称', name : 'cityName', width : 200, sortable : true, align : 'center' }, { display : '城市首字母', name : 'cityFirstLetter', width : 100, sortable : true, align : 'center' }, { display : '热门状态', name : 'hot', width : 150, sortable : true, align : 'center', process : function(value,tDiv, id){ switch ($(tDiv).text()) { case '0': $(tDiv).html("<font color=blue>非热门</font>"); break; case '1': $(tDiv).html("<font color=red>热门</font>"); break; } } }], buttons : [{ name : '删除', bclass : 'delete', onpress : action }, { separator : true },{ name : '添加', bclass : 'add', onpress : action }, { separator : true },{ name : '编辑', bclass : 'edit', onpress : action }, { separator : true }], sortname : "id", sortorder : "asc", usepager : true, useRp : true, checkbox : true,// 是否要多选框 rowId : 'id',// 多选框绑定行的id rp : 10, query:'', showTableToggleBtn : false, height : window.top.document.documentElement.scrollHeight - 240 }); function action(com, grid) { switch (com) { case 'add': ids = ''; $('.trSelected td:nth-child(2) div', grid).each(function(i) { if (i) ids += ','; ids += $(this).text(); }); sta = ''; $('.trSelected td:nth-child(5) div', grid).each(function(i) { if (i) sta += ','; sta += $(this).text(); }); type='SEND'; openDialog(webroot+'sand/messageCodeImportAction!openCityAddPage.action?type='+type+'&ids='+ids,500,200); break; case 'edit': selected_count = $('.trSelected', grid).length; if (selected_count == 0) { jqAlert("请选择需要编辑的记录!","提示"); return; } if (selected_count > 1) { jqAlert("抱歉只能同时修改一条记录!","提示"); return; } ids = ''; $('.trSelected td:nth-child(2) div', grid).each(function(i) { if (i) ids += ','; ids += $(this).text(); }); sta = ''; $('.trSelected td:nth-child(5) div', grid).each(function(i) { if (i) sta += ','; sta += $(this).text(); }); type='SEND'; openDialog(webroot+'sand/messageCodeImportAction!openCityEidtPage.action?type='+type+'&ids='+ids,500,200); break; case 'delete': selected_count = $('.trSelected', grid).length; if (selected_count == 0) { jqAlert("请选择需要删除的记录!","提示"); return; } ids = ''; $('.trSelected td:nth-child(2) div', grid).each(function(i) { if (i) ids += ','; ids += $(this).text(); }); jqConfirm('确定删除?', '确认', function(r) { if(r){ url='sand/messageCodeImportAction!doCityDelete.action'; $.ajax({ url : webroot+url, data : { ids : ids, }, type : 'POST', success : function(backdata) { if($.trim(backdata)=="00"){ jqAlert("删除成功!","提示",function(){ $('#flexgrid').flexReload();// 表格重载 }); } } }); }else{ return; } }); break; } } function cancelSome(ids) { url='sand/messageCodeImportAction!doCancelBatch.action'; cancelOperation(ids,url); } function cancel(ids) { url='sand/messageCodeImportAction!doCancel.action'; cancelOperation(ids,url); } function cancelOperation(ids,url) { $.ajax({ url : webroot+url, data : { ids : ids }, type : 'POST', success : function(backdata) { if($.trim(backdata)=="00"){ jqAlert("作废成功!","提示",function(){ $('#flexgrid').flexReload();// 表格重载 }); } else if($.trim(backdata)=="01"){ jqAlert("系统异常,作废失败!请联系管理员!","提示",function(){ }); } } }); } function modify() { url ='sand/messageCodeImportAction!doModify.action'; opertionVerify(ids,url); } function verify(ids) { url ='sand/messageCodeImportAction!doVerify.action'; opertionVerify(ids,url); } function opertionVerify(ids,url) { $.ajax({ url : webroot+url, data : { ids : ids }, type : 'POST', success : function(backdata) { if($.trim(backdata)=="00"){ jqAlert("审核成功!","提示",function(){ $('#flexgrid').flexReload();// 表格重载 }); } else if($.trim(backdata)=="01"){ jqAlert("系统异常,作废失败!请联系管理员!","提示",function(){ }); } } }); } }); function search(){ var dt = $('#searchform').serializeArray(); $("#flexgrid").flexOptions( { params :dt }); $('#flexgrid').flexOptions( { newp :1 }).flexReload(); }url : webroot+'sand/messageCodeImportAction!getPagedCityList.action',这是结合struts一起的开发
public void getPagedCityList() { String pagenum = Struts2Utils.getParameter("page"); // 页码 String pagesize = Struts2Utils.getParameter("rp");// 每页记录数 String name = Struts2Utils.getParameter("name");// 每页记录数 String code = Struts2Utils.getParameter("code");// Integer start = 1; Integer limit = 10; if (StringUtils.isNotBlank(pagesize)) { limit = Integer.parseInt(pagesize); } if (StringUtils.isNotBlank(pagenum)) { start = (Integer.parseInt(pagenum) - 1) * limit; } PagedQueryResult paged = cityService.getPagedCityList(start, limit, name, code); Struts2Utils.renderJson(JsonUtils.toPagedJsonStr(paged, pagenum)); }
蓝色皮肤
蓝色皮肤下的修改
灰色皮肤
灰色皮肤下的修改