Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jqGrid with an editable checkbox column

When using jqGrid how do you force a cell to load in its editable view on page load as well as when it is clicked?

If you set up 'cell editing' like below, the check box only appears when you click on the cell.

{ name: 'MyCol', index: 'MyCol', editable:true, edittype:'checkbox', editoptions: { value:"True:False" },  cellEdit:true, 

Also on clicking checkbox, is there a way of sending a AJAX post to server instantly rather than having to rely on the user pressing enter?

like image 491
dev Avatar asked May 30 '09 03:05

dev


1 Answers

To allow the checkboxes to always be click-able, use the checkbox formatter's disabled property:

{ name: 'MyCol', index: 'MyCol',    editable:true, edittype:'checkbox', editoptions: { value:"True:False"},    formatter: "checkbox", formatoptions: {disabled : false} , ... 

To answer your second question, you will have to setup an event handler for the checkboxes, such that when one is clicked a function is called to, for example, send an AJAX POST to the server. Here is some example code to get you started. You can add this to the loadComplete event:

    // Assuming check box is your only input field:     jQuery(".jqgrow td input").each(function(){         jQuery(this).click(function(){             // POST your data here...         });     }); 
like image 157
Justin Ethier Avatar answered Sep 22 '22 12:09

Justin Ethier