思路:根据相关参数,动态的成对应该的参数列。设置到Flexgrid参数中。
js对应该的方法:
function roleselect(){
$.ajax({
url:'workform-main!getColumBySpcode.action?opttype=' +$('#opttype').val(),//请求列信息的地址
dataType:'json',
success:function(data){
var json = eval(data);
// op为包含列信息的数组
var op=new Array();
// 迭代返回数据 读出读出每个列信息拼装成对象填入数组
$.each(json, function(i,item){
if(i==0){
op.push({display: item.display, name : item.name, width : 50, sortable : true, align: 'center',hide: true,toggle : false});
}else if(i==1){
op.push({display: item.display, name : item.name, width : 80, sortable : true, align: 'center',process:clickrow});
}else{
op.push({display: item.display, name : item.name, width : 120, sortable : true, align: 'left'});
}
});
// 重画grid
var w = $("#ptable").width() - 3;
grid=$("#flexTable").flexigrid({
width: w ,
height: 250,
url: 'workform-main!getData.action?type=' + $('#type').val() ,
dataType: 'json',
colModel : op,
searchitems : [
{display: '客户编码', name : 'customerid', isdefault: true},
{display: '客户名称', name : 'customername',operater: "Like"},
{display: '工单类型', name : 'wftype',operater: "Like"},
{display: '工单状态', name : 'wfstate',operater: "Like"}
],
errormsg: '发生异常',
sortname: "id",
sortorder: "desc",
//qop: "Eq",//搜索的操作符
usepager: true,
//title: '详细信息列表',
//pagestat: '显示记录从{from}到{to},总数 {total} 条',
useRp: false,
rp: 10000,
//rpOptions: [10, 15, 20, 30, 40, 100], //可选择设定的每页结果数
nomsg: '没有符合条件的记录存在',
minColToggle: 1, //允许显示的最小列数
showTableToggleBtn: true,
autoload: true, //自动加载,即第一次发起ajax请求
resizable: true, //table是否可伸缩
procmsg: '加载中, 请稍等 ...',
hideOnSubmit: true, //是否在回调时显示遮盖
showcheckbox: true,//是否显示第一列的checkbox(用于全选)
gridClass: "bbit-grid",//样式
rowhandler: contextmenu,//是否启用行的扩展事情功能,在生成行时绑定事件,如双击,右键菜单等
rowbinddata: true,//配合上一个操作,如在双击事件中获取该行的数据
onrowchecked: callme,//在每一行的的checkbox选中状态发生变化时触发某个事件
//onrowchecked: false//在每一行的的checkbox选中状态发生变化时触发某个事件
striped:false,
blockOpacity: 0.5//透明度设置
});
}
});
}
java Action 代码:
public String getColumBySpcode() {
setActionInfo();
String opttype = this.getRequest().getParameter("opttype");
JSONArray array = new JSONArray();
if ("runtype".equals(opttype)) {
array.put(new JSONObject(new FlexGridColumnVo("编号","id")));
array.put(new JSONObject(new FlexGridColumnVo("客户编码","customerid")));
array.put(new JSONObject(new FlexGridColumnVo("电话号码","photono")));
array.put(new JSONObject(new FlexGridColumnVo("客户名称","customername")));
}else{
array.put(new JSONObject(new FlexGridColumnVo("编号","id")));
array.put(new JSONObject(new FlexGridColumnVo("客户编码","customerid")));
array.put(new JSONObject(new FlexGridColumnVo("电话号码","photono")));
array.put(new JSONObject(new FlexGridColumnVo("客户名称","customername")));
array.put(new JSONObject(new FlexGridColumnVo("客户级别","lever")));
array.put(new JSONObject(new FlexGridColumnVo("基本商品","basepro")));
array.put(new JSONObject(new FlexGridColumnVo("CMIP","cmip")));
array.put(new JSONObject(new FlexGridColumnVo("是否已回填","fullback")));
}
JSON_OBJECT = array.toString();
return setJsonObject();
}
private void setActionInfo() {
this.getResponse().setContentType("text/html");
this.getResponse().setCharacterEncoding("utf-8");
this.getResponse().setHeader("Pragma", "no-cache");
this.getResponse().setHeader("Cache-Control", "no-cache, must-revalidate");
this.getResponse().setHeader("Pragma", "no-cache");
}
private String setJsonObject() {
try {
HttpServletRequest request = this.getRequest();
System.out.println(request.getParameter("username"));
this.getResponse().getWriter().write(JSON_OBJECT);
this.getResponse().getWriter().flush();
this.getResponse().getWriter().close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
分享到:
相关推荐
jquery脚本实现动态添加列,删除指定列
jQuery设置表格列字段筛选改变代码,jQuery设置表格列字段筛选改变代码(html)
NULL 博文链接:https://xylonwang.iteye.com/blog/554018
本文实例讲述了Jquery动态列功能。分享给大家供大家参考,具体如下: 看到有人写的一个JQUERY动态列, 值得参考, 特转发下来 <!DOCTYPE html> <html> <head> <meta ...
JQuery实例动态生成树 JQuery实例动态生成树 JQuery实例动态生成树 JQuery实例动态生成树 JQuery实例动态生成树
主要介绍了jQuery实现动态给table赋值的方法,结合具体实例形式分析了jQuery动态操作table表格节点的相关技巧,需要的朋友可以参考下
使用jQuery实现动态可编辑表格,代码更少,兼容性更好
数据展示时候,经常从后台传入大小不等的矩阵。这里给出了根据不同矩阵大小,通过jquery的html()和append()方法动态生成html表格的实例。
下面小编就为大家带来一篇jQuery为动态生成的select元素添加事件的方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧
用jquery实现table拖拽列功能,可动态改变表格列宽度,并且实现table表格100%的问题,如果列缩小,则自动拉伸最后一列以实现table100%的效果,如果拉伸长度比原长度大,则显示x滚动条。
主要介绍了jQuery实现动态添加、删除按钮及input输入框的方法,涉及jQuery事件响应及页面元素动态操作相关实现技巧,需要的朋友可以参考下
亲测,支持浏览器IE11, 谷歌,Opera,QQ浏览器,火狐等 主流浏览器。
jquery实现动态背景效果
jquery实现动态背景效果.rar
jquery iframe动态添加tab选项卡 jquery iframe动态添加tab选项卡 jquery iframe动态添加tab选项卡 jquery iframe动态添加tab选项卡 jquery iframe动态添加tab选项卡 jquery iframe动态添加tab选项卡 jquery iframe...
本人这段时间正巧要做一个省市县的树状结构图,公司之前用的dtree实现起来效率太低,半天打不开页面,于是考虑用jquery动态加载,通过网上查资料,学习别人的列子,现将本人所整理的树状结构实例上传。测试数据库为...
jQuery动态添加删除编辑标签代码是一款自定义选项卡,添加选项卡,删除选项卡,编辑选项卡内容等。 jQuery动态添加删除编辑标签代码截图
jQuery制作动态表单验证代码插件,动态验证信息
jquery动态分页数据获取代码 jquery动态分页数据获取代码