this is related to my latest question in this link. i already figured out the whats the error why it displays "Server Error: Parameter 'dataType' is not specified". It's the filter="[{'name':'main_account_group_code','comparison':'starts_with','value':$('#searchCode').val()}]";
to
filter=[{'name':'main_account_group_code','comparison':'starts_with','value':$('#searchCode').val()}];
now, my grid successfully displays the data in searching. My question is, is there another way to do this without using a global variable? My senior told me that its a bad practice and to try something else. I also have this feeling that there is still one best way in displaying my search data in the jqgrid (rather than using a global), but i just dont know how to do it.
I've been solving this problem on my own for days now, but still i still dont have the best method on how to do this (still stuck). anybody help..
EDIT: This is my jqgrid code.
$("#list1").jqGrid({
url: '',
datatype: 'local',
jsonReader : {
root: function(obj) {
var root = [];
if ('error' in obj)
{
showMessage(obj.error['class'] + ' error: ' + obj['error']['msg']);
}
else
{
$.each(obj['result']['main']['rowdata'], function(rowIndex, rowDataValue) {
var row = {};
$.each(rowDataValue, function(columnIndex, rowArrayValue) {
var fldName = obj['result']['main']['metadata']['fields'][columnIndex].name;
row[fldName] = rowArrayValue;
});
root[rowIndex] = row;
});
};
return root;
},
page: "result.main.page",
total: "result.main.pageCount",
records: "result.main.rows",
repeatitems: false,
id: "0"
},
colNames:['Code', 'Description','Type'],
colModel:[
{name:'code'},
{name:'desc'},
{name:'type'}
],
postData: {
filters:[{"name":"main_account_group_code", "comparison":"starts_with", "value":$('#searchCode').val()}]
},
rowNum:10,
viewrecords: true,
rowList:[10,50,100],
pager: '#tblDataPager1',
sortname: 'desc',
sortorder: 'desc',
loadonce:false,
height: 250,
caption: "Main Account"
});