带有数字类型而不是对象的jqGrid userData [英] jqGrid userData with numeric type instead of object

查看:170
本文介绍了带有数字类型而不是对象的jqGrid userData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只想在这里确认一下.可以直接将jqGrid的userData与javascript类型一起使用(与使用带有字段的对象相对)吗?

Just want to confirm something here. Is it possible to use jqGrid's userData with a javascript type directly (as opposed to using an object with field(s))?

如果我修改了

If I modify the example in the jqGrid doc, I would like to return this json to jqGrid:

{ 
  total: "xxx", 
  page: "yyy", 
  records: "zzz", 
  userdata: 0, 
  rows : [ 
    {id:"1", cell:["cell11", "cell12", "cell13"]}, 
    {id:"2", cell:["cell21", "cell22", "cell23"]}, 
    ... 
  ] 
}

并让jQuery("grid_id").jqGrid('getGridParam', 'userData')返回0.

目前看来,它返回的是一个空对象{ }.

Presently it seems to return an empty object { } instead.

我使用jqGrid 4.4.1.

I use jqGrid 4.4.1.

推荐答案

userdata部分应为 object .如果您需要在userdata内部返回标量,则应使用类似

userdata part of the JSON input for jqGrid should be object. If you need to return scalar inside of userdata you should use something like

"userdata": { mycounter: 0 }

然后使用

var userdata = $("#grid_id").jqGrid("getGridParam", "userData");
if (userdata) {
    alert(userdata.mycounter);
}

这篇关于带有数字类型而不是对象的jqGrid userData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆