Jqgrid single select checkbox

In Jqgrid, I want to restrict the user so that only one checkbox can be selected at any time. When the user selects several flags, only the last one is selected in order to be in the "selected" state, the rest should not be automatically selected.

I set the multi select attribute to true. But I can not delete the previously selected item. Is it possible to do, if so, how?

thanks

+4
source share
4 answers

You can use the beforeSelectRow event and reset the selection:

beforeSelectRow: function(rowid, e) { jQuery("#list47").jqGrid('resetSelection'); return(true); } 

I have a fiddle so you can check how this works.

+9
source

You need to do a few more things:

1. Set multiboxonly to true and multiselect to true

2. Define the onSelectRow and beforeSelectRow :

3. Define a global variable: var lastSel ;


Implementation of onSelectRow and beforeSelectRow :

 onSelectRow: function (rowId, status, e) { if (rowId == lastSel) { $(this).jqGrid("resetSelection"); lastSel = undefined; status = false; } else { lastSel = rowId; } }, beforeSelectRow: function (rowId, e) { $(this).jqGrid("resetSelection"); return true; } 
+3
source

Having a checkmark in each column implies that you can click several times at a time. What you're asking for is basically the behavior of multiselect: false , but with the checkbox column - are you sure you really want to check the boxes in this case?

+2
source

I know this question is old, but I found a better solution in this Stack Post .

All you have to do is set the following two jqGrid properties:

 multiselect:true // multi-select checkboxes appear multiboxonly:true // checkboxes act like radio buttons where only one is selected at a time 

I updated the script made by LeftyX to just use the multiboxonly parameter on this JsFiddle

This is what I need. It may help someone else.

0
source

All Articles