在使用 JQGrid 表单的时候,默认请求是异步的,不会阻塞后面的方法,但有时候需要在后面方法中对页面数据获取到时候在进行操作。
增加配置:
ajaxGridOptions:{async: false},//使用同步的方式,true为异步方式
/* 生成原始档案任务列表 */ grid = $("#queryData_1").jqGrid({ url: '${_ctx}/data/statisticTaskList.do', ajaxGridOptions:{async: false},//使用同步的方式,true为异步方式 mtype: 'post', datatype: "local", height: 410, autowidth: true, colModel: [ {name:"taskCode", label:"项目编码", width:200, align:"center",sortable: false}, {name:"name", label:"项目名称", width:200, align:"center",sortable: false}, {name:"content", label:"工作内容", width:210, align:"center",sortable: false}, {name:"creatorTime",label:"创建时间", width: 150, align: "center", sortable: false,formatter:function(cellvalue, options, rowdata){ return cellvalue!=null?cellvalue.dateFormat("yyyy-MM-dd"):""; }} ], postData: { }, id:"id", pgbuttons:true, viewrecords: true, pagerpos:"center", altRows:true, sortname: "id", sortorder: "desc", jsonReader : { root: "datas", // json中代表实际模型数据的入口 repeatitems: false // 如果设为false,则jqGrid在解析json时,会根据name来搜索对应的数据元素(即可以json中元素可以不按顺序);而所使用的name是来自于colModel中的name设定。 }, prmNames : { } });