Reputation: 327
Been doing a custom jqgrid and 2 different method is giving me different result:
This method will give me accurate total of record IF I do a "direct" input (see &Input=1 in URL):
$('#1ASList').jqGrid({
url: DateFile+'Data.php?Load=AllianceStatus&Input=1',
datatype: 'json',
colModel: [{name:'A',width:64,align:'left'},{name:'C',width:25,align:'right',formatter:'integer'}],
altRows: true,
height: 102,
gridComplete: function(){ $('#1ASTtl').empty().html('[ '+$(this).jqGrid('getGridParam','records')+' ]'); }
});
This method will give me blanks and the 3rd Grid will give me total result, which I do not want. I want each Grid to give me their own results:
for(var iAlliS = 0; iAlliS < 3; iAlliS++){
$('#'+iAlliS+'ASList').jqGrid({
url: DateFile+'Data.php?Load=AllianceStatus&Input='+iAlliS,
datatype: 'json',
colModel: [{name:'A',width:64,align:'left'},{name:'C',width:25,align:'right',formatter:'integer'}],
altRows: true,
height: 102,
gridComplete: function(){ $('#'+iAlliS+'ASTtl').empty().html('[ '+$(this).jqGrid('getGridParam','records')+' ]'); }
});
}
Why do both give me different result? What am I missing here? (I am not using FooterData, all custom results)
Upvotes: 1
Views: 254
Reputation: 12491
Ok, let's try this. Instead of using gridComplete
event of jqgrid
use loadComplete
it has one parameter data
which has full data from the server. So you can change your code like this:
for(var iAlliS = 0; iAlliS < 3; iAlliS++){
$('#'+iAlliS+'ASList').jqGrid({
url: DateFile+'Data.php?Load=AllianceStatus&Input='+iAlliS,
datatype: 'json',
colModel: [{name:'A',width:64,align:'left'},{name:'C',width:25,align:'right',formatter:'integer'}],
altRows: true,
height: 102,
loadComplete: function(data){ $('#'+iAlliS+'ASTtl').empty().html('[ '+data.records+' ]'); }
});
}
So you should not have any more problem to get data from DOM
and get it directly from JSON
that comes from server.
Upvotes: 1