views:

1591

answers:

1

When using jqGrid how do you force a cell to load in its editable view on page load aswell 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.

+6  A: 

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...
        });
    });
Justin Ethier
@Justin Great answer!! Thanks, if it was my question, I'd give you the tick.
Dan
Fantastic! I wish I could mark this as the selected answer!
Nigel
You're welcome! Its a shame this question is so old, but hopefully the answer can still be helpful :)
Justin Ethier
Well is kinda old - I virtually re-wrote it.
Dan
Ah I see now in the history. Well in that case, nevermind :)
Justin Ethier