1
votes

I am using JqxGrid with selectionmode:checkbox.

I am able to alert when the checkbox is checked and unchecked using the rowselect and rowunselect functions.

Problem is I need to only allow the user 4 selections. Hence when he checks the 5th checkbox I show him an alert and => 'uncheck' this checkbox.

I am able to do everything except : 'uncheck' this last checked checkbox

Since this is not a real checkbox not sure what to check.

I am using the code at http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/checkboxselection.htm

as base and calling rowselect and rowunselect functions.

1

1 Answers

1
votes

You should be able to 'cancel' the select by calling rowunselect using the rowId from the row select event:

 $('#jqxgrid').on('rowselect', function (event) {
    if( $('#jqxgrid').jqxGrid('getselectedrowindexes').length > 4 ) {
        $('#jqxgrid').jqxGrid('unselectrow', event.args.rowindex);
    }
    else {
        // whatever
    }
 });