I want to use a grid as subgrid in jqGrid because I read that “simple subgrid” doesn’t allow cell edit.
I’m filling main Grid with dataType function successfully and I’m trying to do the same for subgrid, but subgrid shows without data, and I don’t know why because I debugged and I catch data correctly from web service, but when I go through the data doing a addRowData to the subgrid seems to have no effect.
I’m using a a ASP.Net 2.0 web service and JSON,Here is the client code, any idea :-S? Thanks 🙂
EDIT:
I added a:
function ReceivedClientData(data) {
var thegrid = $("#" + gridId);
if ($(thegrid).length == 0) alert('NOT EXISTS');
thegrid.clearGridData();
for (var i = 0; i < data.length; i++)
thegrid.addRowData(i + 1, data[i]);
}
And I receive a NOT EXISTS for subgrid, I don’t know if is the best way to check if a selector exists but this would mean that I can’t find “the dynamic ” created by jqgrid when I capture the ajax postback? How can I fill the subgrid?
EDIT 2:
I think that I was wrong with subgrid ID, now I’m saving in a variable the grid_id
subGridRowExpanded: function(subgrid_id, row_id) {
subGridID = subgrid_id;
and using it when callback, but I’m receiving a p.rownumbers is null from jqgrid.js when I try to addRowData. :-S any suggestions?
function ReceivedClientDataForSubGrid(data) {
var thegrid = $("#" + subGridID);
if ($(thegrid).length == 0) alert('NOT EXISTS');
thegrid.clearGridData();
for (var i = 0; i < data.length; i++)
thegrid.addRowData(i + 1, data[i]);
}
Moving the “Edit 3” to an answer to mark the question as answered
I solved it, I was accesing to an incorrect ID, the correct ID is var thegrid = $(“#” + subGridID + “_t”);
complete client code