The question is almost complete in the title: is there any way, using jquery, to find the element that is handled by a jqGrid object?
To be more precise, I wish to call a reload method on the grid, if one is present on the page.
I am using the following code
...
success: function (data) {
//Check if there is a jqGrid on the page and if present, reloads its data
var jqGrid = $('.ui-jqgrid');
if ( jqGrid.length ) {
//get the grid id. The actual id object is in the form of "gbox_your_grid_id"
var gridid = "#" + jqGrid.attr('id').substring(5);
//time to reload
$(grid).trigger('reloadGrid');
}
}
but it seems that the reloadGrid method is never called. Any suggestion?
It’s difficult to suggest any test which will be perfect. You can try for example to search for the “gbox”:
$('div.ui-jqgrid')– it is a div which contain all components of jqGrid. If$('div.ui-jqgrid').length > 0then exist at least grid on the page.You can search for the
tableelement inside of bdiv:or even for
(see here for details). Additionally you can test whether such table elements have
jqGridmethod: