wsdydmw 2011-08-17 14:42
浏览 592
已采纳

jqgrid中显示的值如何通过不同的表名参数来显示不同表的值

[size=large]比如我现在获取了一个字符串 这个字符串是某表的名字,我使用了dwr方法 如何通过这个表名字符串来动态设置dwrFun的值,还有显示出来的列名又如何改变呢,这是我现在的代码[/size]
[code="js"]var gridSetting={
url : 'http://127.0.0.1:8080/WebConnector/data.jsp',
height:'auto',
width:'auto',
datatype : "json",
//dwrFun : OperatorService.findMapByProperty,
dwrCountFun :OperatorService.findCountByProperty,
condition : "",
searchCondition : '',
selectCondition : '',
needLink : true,
dwr : true,
autowidth:true,
colNames : [ 'ID', '姓名', '部门编号'],
colModel : [ {
key:true,
name : 'operatorCode',
index : 'operatorCode'
}, {
name : 'operatorName',
index : 'operatorName'
}, {
name : 'organization',
index : 'organization',
sortable : false
}],
rowNum : 10,
rowList : [ 10, 20, 30 ],
pager : '#operatorPager',
viewrecords : true,
rownumbers : false,
jsonReader : {
root : "rows",
page : "page",
total : "total",
records : "records", // 总记录数
repeatitems : false
// 设置成false,在后台设置值的时候,可以乱序。且并非每个值都得设
},
multiselect:true,
multiboxonly:true

    };

[/code]
然后这个方法是实现dwrfun的动态改变
[code="js"]if(tablename="Operator")//tablename是传入的表名参数
{
jQuery('#operatorTable').setGridParam({dwrFun:OperatorService.findMapByProperty})
}
else if(tablename="Article")
{
jQuery('#operatorTable').setGridParam({dwrFun:ArticleService.findMapByProperty})
}[/code]
grid显示列名又如何动态改变呢

  • 写回答

2条回答

  • conanca 2011-08-17 15:01
    关注

    var aaa = 你的dwrFun的值
    var bbb = 你的列名
    $("#YourListID").setGridParam({dwrFun:aaa, colNames : [ 'ID', '姓名', bbb]}).trigger("reloadGrid");

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料