I am trying two versions of the code, one with local data type and another with json data type. All I am trying to do is print the data to the console log, with this line console.log(texts)
. However, this is printing to the console ONLY when data type is local. Below are two versions of the code, local data type and json data type. Both versions are similar with only dataTypes changed. I am calling someFunc
in the end to print the data
local datatype
$(document).ready(function() {
var mydata = [
{id: "1", name: "someone"}
]
someFunc = function(columnName) {
var texts = jQuery("#myGrid").jqGrid('getCol',columnName);
console.log(texts); //is printing only when datatype is local
};
jQuery("#myGrid").jqGrid(
{
autoencode:true,
mtype: 'GET',
datatype : 'local',
data: mydata,
colModel : [
{name: 'name', index: 'Name'}
]
});
jQuery("#mygrid").jqGrid('navGrid', '#pager', {
edit : false,
add : false,
del : false,
search : true
}, {}, {}, {}, {
sopt : [ 'eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew' ],
closeOnEscape : true,
multipleSearch : true,
closeAfterSearch : true
});
someFunc('name');
});
Json Data type
$(document).ready(function() {
someFunc = function(columnName) {
var texts = jQuery("#myGrid").jqGrid('getCol',columnName);
console.log(texts); //is printing only when datatype is local
};
jQuery("#myGrid").jqGrid(
{
url : 'someUrlToGetData',
autoencode:true,
mtype: 'GET',
datatype: 'json',
colModel : [
{name: 'name', index: 'Name'}
]
});
jQuery("#mygrid").jqGrid('navGrid', '#pager', {
edit : false,
add : false,
del : false,
search : true
}, {}, {}, {}, {
sopt : [ 'eq', 'ne', 'lt', 'gt', 'cn', 'bw', 'ew' ],
closeOnEscape : true,
multipleSearch : true,
closeAfterSearch : true
});
someFunc('name');
});