I have 3 simple questions.
I have some code that tells me if a jqGrid object is present in the page:
//Check if there is a jqGrid on the page and if present, reloads its data ;) var jqGrid = $('div.ui-jqgrid-bdiv table'); if (jqGrid.length) { //time to reload $(jqGrid).trigger('reloadGrid'); }
I would like to find the pager ID element if there is one. Is there any way to do this?
Suppose I have a custom class in my jqGrid table:
<table id="myGrid" runat="server" class="customclass"></table> <div id="myGrid_pager" runat="server"></div>
How do I check the presence of customclass inside my jqGrid dynamically?
EDIT:
With Oleg help I have been able to code a reconfigPermissions()
function that show/hide default Add, Edit and Delete buttons. Here is the function:
function reconfigPermissions(gridID) {
var enableRegistry = CanModifyRegistry();
var ops = ['#add_' + gridID, '#edit_' + gridID, '#del_' + gridID];
$.each(ops, function (ix, value) {
var $td = $(value);
if (enableRegistry === true) {
$td.show();
} else {
$td.hide();
}
});
}
This function get called when the user select another range of dates in a combo box defined elsewhere in the page.
The problem is the following: if, when the grid is initially loaded, the user has rights to the default period (selected in the combo box) everything works. You can switch the date range in the combo and the buttons appear and disappear correctly.
Unfortunately if the user has no rights on the default period initially selected (so the first creation of the grid has {add: false, edit: false, del: false}
) even switching to a period where the user has rights does not add the buttons at all.
This is the code binded to the combo box change
event handler
$.ajax({
url: GetBaseWSUrl() + 'MyWebService.asmx/ChangeCurrentPeriod',
type: "post",
dataType: "json",
async: false,
data: JSON.stringify({ periodID: $(this).val() }),
contentType: "application/json; charset=utf-8",
success: function (data) {
//Check if there is a jqGrid on the page and if present, reloads its data
var jqGrids = $('div.ui-jqgrid-bdiv table');
jqGrids.each(function (ix, jqGrid) {
var gridID = $.jgrid.jqID(jqGrid.id)
reconfigPermissions(gridID);
jqGrid.trigger('reloadGrid');
});
}
});
Any suggestion?