动态列如何加载
求问,如何动态加载列?我的想法是在加载之前调用方法,然后动态生成。之后再去加载数据。请问怎么实现呢?因为用的是自定义标签。不是很了解。无法获取id 。如何增加加载前调用的方法。loadBefore
[*]var options={};
[*]$(function(){
[*] var myNj = 9;
[*] //初始化
[*] $("#disgrid").datagrid({
[*] type: 'POST',
[*] nowrap: false,
[*] striped: true,
[*] fit:true,
[*] width:1024,
[*] height:500,
[*] url:'',
[*] pageSize:30,
[*] remoteSort: false,
[*] pagination:true,
[*] rownumbers:true,
[*] singleSelect:true,
[*] queryParams:{
[*] nj:myNj,
[*] unitType:1
[*] }
[*] });
[*]
[*] fetchData(myNj);
[*]});
[*]
[*]function fetchData(nj) {
[*] var s = "";
[*] s = "[[";
[*] s = s + "{field:'unitname',title:'单元',width:160},{field:'practicetime',title:'测试时间',width:160},{field:'userid',title:'userid',width:120,hidden:'true'},{field:'serial',title:'serial',width:120,hidden:'true'},{field:'unitid',title:'unitid',width:100,hidden:'true'},";
[*]
[*] //lu todo 列的定义可从服务器获得
[*] if (nj==9) {
[*] s = s + "{field:'aipanel_text_exam',title:'短文朗读',width:80},{field:'aipanel_scene_exam',title:'情景对话',width:80},{field:'aipanel_oral_exam',title:'简短说话',width:80}";
[*]
[*] //lu 加一个计算列
[*] s = s + ",{field:'tatal_score',title:'总分',width:60,formatter:function(value,rec){return paraseIntValue(rec.aipanel_text_exam)+paraseIntValue(rec.aipanel_scene_exam)+paraseIntValue(rec.aipanel_oral_exam);}}";
[*] }else if (nj==7||nj==8){
[*] //....
[*]}
[*] s = s + "]]";
[*] options={};
[*] options.url = '/app/search.do';
[*] options.queryParams = {
[*] nj:nj,
[*] unitType:1
[*] };
[*] options.columns = eval(s);
[*] //lu 增加一列
[*] options.columns.push(
[*] {
[*] field:'desc',title:'查看详情',width:60,
[*] formatter:function(value,rec){
[*] return "<a href=\"javascript:showDescInfo(\'"+rec.serial+"\',\'"+rec.scene_score+"\',\'"+rec.total_score+"\');\">详情</a>";
[*] }
[*] }
[*] );
[*]
[*] $('#disgrid').datagrid(options);
[*] $('#disgrid').datagrid('reload');
[*]
[*]}
可以参考下 fly1206 发表于 2018-3-27 15:46 static/image/common/back.gif
[*]var options={};
[*]$(function(){
[*] var myNj = 9;
$('#techownReportList').datagrid({
onBeforeLoad: function () {
var m = $('#techownReportList').datagrid('options').queryParams;
m.date_begin = '2011-11-11';
m.date_end = '2018-10-10';
$('#techownReportList').datagrid('reload');
}
});
我这么写的但不知道为什么会抛出异常。难道所有项都要重新写么 ?
jquery-1.8.3.js:418 Uncaught RangeError: Maximum call stack size exceeded
at Function.isFunction (jquery-1.8.3.js:418)
at Function.each (jquery-1.8.3.js:584)
at init.each (jquery-1.8.3.js:241)
at Object.reload (jquery.easyui.min.1.3.2.js:8087)
at init.$.fn.datagrid (jquery.easyui.min.1.3.2.js:7924)
at HTMLTableElement.onBeforeLoad (techownAccountDetailsController.do?list:35)
at _576 (jquery.easyui.min.1.3.2.js:7858)
at HTMLTableElement.<anonymous> (jquery.easyui.min.1.3.2.js:8088)
at Function.each (jquery-1.8.3.js:611)
at init.each (jquery-1.8.3.js:241)
页:
[1]