Javascript 要从服务器响应在jqgrid中显示动态列名,请参阅如何使用ajax调用编写loadcomplete事件
jqgrid中的动态列名获取没有列名和数据的空白网格时出现问题? 在jqgrid中获取平淡的网格名称和日期这里是我的代码,我找不到 为什么我使用loadcoplete事件和ajax调用得到空白网格 提前谢谢 这是我的密码Javascript 要从服务器响应在jqgrid中显示动态列名,请参阅如何使用ajax调用编写loadcomplete事件,javascript,jquery,jqgrid,Javascript,Jquery,Jqgrid,jqgrid中的动态列名获取没有列名和数据的空白网格时出现问题? 在jqgrid中获取平淡的网格名称和日期这里是我的代码,我找不到 为什么我使用loadcoplete事件和ajax调用得到空白网格 提前谢谢 这是我的密码 <script type="text/javascript"> var jq = jQuery.noConflict(); jq(function() { jq("#grid").jqGrid({ url:'<%= requ
<script type="text/javascript">
var jq = jQuery.noConflict();
jq(function() {
jq("#grid").jqGrid({
url:'<%= request.getContextPath() %>/admin/dataGrid',
datatype: "json",
colNames:['','','','','',
'','','','','',
'','','','','',
'','','','','',
'','','','','',
'','','','',''],
colModel:[
{name:'p1',index:'p1', width:55,align:"right",hidden: true ,formatter:'date', formatoptions: {srcformat:'ISOLong', newformat:'H:i:s'}},
{name:'p2',index:'p2', width:55,align:"right",hidden: true },
{name:'p3',index:'p3', width:55,align:"right",hidden: true },
{name:'p4',index:'p4', width:55,align:"right",hidden: true },
{name:'p5',index:'p5', width:55,align:"right",hidden: true },
{name:'p6',index:'p6', width:55,align:"right",hidden: true},
{name:'p7',index:'p7', width:55,align:"right",hidden: true},
{name:'p8',index:'p8', width:55,align:"right",hidden: true},
{name:'p9',index:'p9', width:55,align:"right",hidden: true},
{name:'p10',index:'p10', width:55,align:"right",hidden: true},
{name:'p11',index:'p11',width:55,align:"right",hidden: true},
{name:'p12',index:'p12',width:55,align:"right", hidden: true},
{name:'p13',index:'p13',width:55,align:"right", hidden: true},
{name:'p14',index:'p14',width:55,align:"right",hidden: true},
{name:'p15',index:'p15', width:55,align:"right",hidden: true},
{name:'p16',index:'p16', width:55,align:"right",hidden: true},
{name:'p17',index:'p17', width:55,align:"right",hidden: true},
{name:'p18',index:'p18', width:55,align:"right",hidden: true},
{name:'p19',index:'p19', width:55,align:"right",hidden: true},
{name:'p20',index:'p20', width:55,align:"right",hidden: true},
{name:'p21',index:'p21', width:55,align:"right",hidden: true},
{name:'p22',index:'p22', width:55,align:"right",hidden: true},
{name:'p23',index:'p23',width:55,align:"right",hidden: true},
{name:'p24',index:'p24',width:55,align:"right", hidden: true},
{name:'p25',index:'p25',width:55,align:"right", hidden: true},
{name:'p26',index:'p26',width:55,align:"right",hidden: true},
{name:'p27',index:'p27',width:55,align:"right",hidden: true},
{name:'p28',index:'p28',width:55,align:"right", hidden: true},
{name:'p29',index:'p29',width:55,align:"right", hidden: true},
{name:'p30',index:'p30',width:55,align:"right",hidden: true},
],
postData: {
},
rowNum:10,
rowList:[10,20,30],
height: 230,
autowidth: true,
rownumbers: true,
pager: '#pager',
viewrecords: true,
emptyrecords: "Empty records",
loadonce: false,
viewrecords: true,
caption:"Meter Data",
footerrow: true,
userDataOnFooter: true,
loadComplete: function() {
alert("load");
/* $ ("#grid").jqGrid('jq',{datatype:'json'}); */
},
jsonReader : {
root: "rows",
page: "page",
total: "totalPages",
records: "records",
repeatitems: false,
cell: "cell",
userdata : "userdata"
},
json : function(jsondata){
$.ajax({
url : '<%= request.getContextPath() %>/admin/dataGrid',
data : jsondata,
dataType :"json",
complete: function(jsondata,stat)
{
if(stat=="success"){
var thegrid = jQuery("#grid")[0];
thegrid.addJSONData(eval("("+jsondata.responseText+")"))
}
}
})
}
});
jq("#grid").jqGrid("setLable",23,"Column23");
jq("#grid").jqGrid("showCol",23);
jq("#grid").jqGrid('navGrid','#pager',
{edit:false,add:false,del:false,search:true},
{ },
{ },
{ },
{
sopt:['eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew'],
closeOnEscape: true,
}
);
});
</script>
var jq=jQuery.noConflict();
jq(函数(){
jq(“网格”).jqGrid({
url:“/admin/dataGrid”,
数据类型:“json”,
colNames:['','','','',
'','','','','',
'','','','','',
'','','','','',
'','','','','',
'','','','',''],
colModel:[
{name:'p1',index:'p1',width:55,align:'right',hidden:true,formatter:'date',formattoptions:{srcformat:'ISOLong',newformat:'H:i:s'},
{name:'p2',index:'p2',width:55,align:“right”,hidden:true},
{名称:'p3',索引:'p3',宽度:55,对齐:“右”,隐藏:真},
{名称:'p4',索引:'p4',宽度:55,对齐:“右”,隐藏:true},
{name:'p5',index:'p5',width:55,align:“right”,hidden:true},
{名称:'p6',索引:'p6',宽度:55,对齐:“右”,隐藏:true},
{name:'p7',index:'p7',width:55,align:“right”,hidden:true},
{name:'p8',index:'p8',width:55,align:“right”,hidden:true},
{name:'p9',index:'p9',width:55,align:“right”,hidden:true},
{name:'p10',index:'p10',width:55,align:“right”,hidden:true},
{名称:'p11',索引:'p11',宽度:55,对齐:“右”,隐藏:true},
{名称:'p12',索引:'p12',宽度:55,对齐:“右”,隐藏:true},
{name:'p13',index:'p13',width:55,align:“right”,hidden:true},
{名称:'p14',索引:'p14',宽度:55,对齐:“右”,隐藏:true},
{名称:'p15',索引:'p15',宽度:55,对齐:“右”,隐藏:true},
{名称:'p16',索引:'p16',宽度:55,对齐:“右”,隐藏:true},
{name:'p17',index:'p17',width:55,align:“right”,hidden:true},
{name:'p18',index:'p18',width:55,align:“right”,hidden:true},
{名称:'p19',索引:'p19',宽度:55,对齐:“右”,隐藏:true},
{name:'p20',index:'p20',width:55,align:“right”,hidden:true},
{name:'p21',index:'p21',width:55,align:“right”,hidden:true},
{name:'p22',index:'p22',width:55,align:“right”,hidden:true},
{name:'p23',index:'p23',width:55,align:“right”,hidden:true},
{name:'p24',index:'p24',width:55,align:“right”,hidden:true},
{name:'p25',index:'p25',width:55,align:“right”,hidden:true},
{name:'p26',index:'p26',width:55,align:“right”,hidden:true},
{name:'p27',index:'p27',width:55,align:“right”,hidden:true},
{name:'p28',index:'p28',width:55,align:“right”,hidden:true},
{name:'p29',index:'p29',width:55,align:“right”,hidden:true},
{名称:'p30',索引:'p30',宽度:55,对齐:“右”,隐藏:真},
],
postData:{
},
rowNum:10,
行列表:[10,20,30],
身高:230,
自动宽度:正确,
行数:对,
寻呼机:“#寻呼机”,
viewrecords:是的,
emptyrecords:“空记录”,
loadonce:false,
viewrecords:是的,
标题:“仪表数据”,
是的,
userDataOnFooter:true,
loadComplete:function(){
警报(“装载”);
/*$(“#grid”).jqGrid('jq',{datatype:'json'})*/
},
jsonReader:{
根:“行”,
第页:“第页”,
总计:“总计页数”,
记录:“记录”,
重复项:false,
细胞:“细胞”,
用户数据:“用户数据”
},
json:函数(jsondata){
$.ajax({
url:“/admin/dataGrid”,
资料来源:jsondata,
数据类型:“json”,
完成:函数(jsondata、stat)
{
如果(统计=“成功”){
var thegrid=jQuery(“#grid”)[0];
addJSONData(eval(“+jsondata.responseText+”))
}
}
})
}
});
jqGrid(“可设置”,23,“第23列”);
jq(“网格”).jqGrid(“showCol”,23);
jqGrid('navGrid','#pager',
{编辑:false,添加:false,删除:false,搜索:true},
{ },
{ },
{ },
{
sopt:['eq','ne','lt','gt','cn','bw','ew'],
closeOnEscape:没错,
}
);
});