[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显示列名又如何动态改变呢