How to add custom flag in JQGrid header

Try as below

jqGrid({
datatype: 'json',
colNames: ["<input type='checkbox' name = 'chkAllOutputField'/>", "other columns" ]
Check box

appears in the header, but the check will not be checked / unchecked no matter how you click it.

How can I make it marked or unchecked by clicking

+3
source share
3 answers

Find one way: How to add a checkbox to jQgrid header

<input type="checkbox" onclick="checkBox(event)" /> 

and added the following method ...

function checkBox(e) 
{ 
   e = e||event;/* get IE event ( not passed ) */ 
   e.stopPropagation? e.stopPropagation() : e.cancelBubble = true; 
} 
+6
source

, , "" , "click", jqGrid . , "foo" (: "foo" ), id = "list", id = "list_foo",

$("th#list_foo").unbind('click');

$("th#list_foo input").click(function(){
    // implement your custom behavior
    alert("clicked!");
});
+3

Here is the best way to make the jqgrid header checkbox work.

If you see the html code, there is a div tag surrounding the input tag that the class has - ui-jqgrid-sortable. This prevents the checkbox from being checked.

Remove it, it works as you expected.

Solution below

Add id to checkbox

<input type="checkbox" id="hdrCbox" onclick="checkBox(event)" />

when initializing the grid or form, add the line below.

$('#hdrCbox').parent().removeClass('ui-jqgrid-sortable');
0
source

All Articles