Yes, itโs true that this is not a very ordinary approach, and basically you said you thought you were doing it, but I found that it was the easiest way to get all the selected lines and also set the header checkbox:
var grid = $("#my_grid"); grid.resetSelection(); $('#cb_my_grid').click(); var ids = grid.getDataIDs(); for (var i=0, il=ids.length; i < il; i++ ) grid.setSelection(ids[i], false);
I believe that no rows will be selected if the header flag is programmatically pressed due to the underlying jqGrid implementation, as you said? I donโt know how it works below, but now it works for me from above.
The main reason I want to make sure the header checkbox is selected in my grids is because the user can subconsciously determine that yes, all the rows in the grid are definitely selected right now (including those not visible below the current scroll view), and donโt have to click on the title to see it.
@Craig - I need to try my method, it seems more simple and reasonable
source share