JqGrid UserData With Numeric Type Instead Of Object
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
Solution 1:
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 }
and then use
var userdata = $("#grid_id").jqGrid("getGridParam", "userData");
if (userdata) {
alert(userdata.mycounter);
}
Solution 2:
OK so after a bit of exploration, it seems the problem is with the value 0. Other values (I tried 1) come back fine, but when it's 0 I get {}.
I also tried changing the reader to use a function instead of the name of the field:
jsonReader: {
...
userdata: function(json) { return json.response.userdata; },
...
}
But the behaviour is exactly the same: {} when the value is 0, 1 when it's 1.
I also updated to 4.4.4 but it doesn't change it.
I don't know if this qualifies as a bug or a non-documented restriction, but I'll return an object with a numerical field instead of the numerical value itself, and it will solve the issue.
Post a Comment for "JqGrid UserData With Numeric Type Instead Of Object"