Using answer from Set rownumbers to false dynamically in jqgrid I created row numbers toggle button. Initially row numbers are not shown. Button click is ignored, row numbers column is not added. How to force button to add row number column ? Or is it possible to add option to column chooser to toggle row number columns ? This would be better, not additional button is required.
var rownumbers= isColState ? myColumnsState.rownumbers : false;
$("#grid_toppager_left table.navtable tbody tr").append(
'<td class="ui-pg-button ui-corner-all">' +
'<div class="ui-pg-div my-nav-checkbox">' +
'<input tabindex="-1" type="checkbox" id="RowNumbers" ' + (rownumbers ? 'checked ' : '')+'/>' +
'<label title="Toggle row numbers"' +
' for="RowNumbers">Toggle row numbers</label></div></td>'
);
$("#RowNumbers").button({
text: false,
icons: {primary: "ui-icon-grip-dotted-vertical"}
}).click(function () {
rownumbers = !rownumbers;
if (rownumbers ) {
$grid.jqGrid('showCol', 'rn');
} else {
$grid.jqGrid('hideCol', 'rn');
}
saveWindowState();
});
Update
jqgrid contains also multiselect and _actions columns. in loadcomplete new row is added to end of grid using
var newRowData = { Dokumnr: 123,
Reanr: $grid[0].rows.length + 1
},
newRowId = '_empty' + $.jgrid.randId();
$grid.jqGrid('addRowData', newRowId, newRowData);
If row numbers are turned on in first time after load, multiselect column checkbox in added row appears in rown numbers column:
How to fix this ?