jqGrid multiselect "check all" in header: how to hide it?
Asked Answered
Y

3

12

I use jqGrid with the multiselect option set to true.

I'm looking for a way to hide or disable the first checkbox (the one in the row of the column names) so that users can't use the "check all/uncheck all" feature.

How to do it?

Yousuf answered 2/6, 2011 at 9:15 Comment(0)
T
25

The checkbox in the header has the id which is combined from the "cb_" prefix and the grid id. So you can hide the element with

var myGrid = $("#list");
$("#cb_"+myGrid[0].id).hide();
Toms answered 2/6, 2011 at 10:7 Comment(5)
This is the best way I've found to do this.Artery
What if the target list does not has an id?Railey
@AmirAliAkbari: I don't understand your question. What "target list" you mean?Toms
@Toms I meant converting a table with no id (<table class="x">) to a jqgrid, but apparently jqgrid requires the <table> to have an id.Railey
@AmirAliAkbari: Sorry, but my answer was about jqGrid. You can't create grid from <table> element which has no id. It's one from base requirement of jqGrid.Toms
D
0

Find the div of checkbox and hide/overwrite its inner HTML.

Discoloration answered 2/6, 2011 at 9:49 Comment(0)
S
0

If you have runat parameter

<trirand:JQGrid ID="grdTest" runat="server" 
"MultiSelect="true" MultiSelectMode="SelectOnRowClick">
    <Columns>
    <!-- cols -->
    </Columns>

     <ClientSideEvents GridInitialized="GrdInit" /><!-- add this -->
    </trirand:JQGrid>

On your page:

function getCont(control)
{
    if(control == "grdTest")
    { 
       return $("#<%= grdTest.ClientID %>"); 
    }
}

Then in your js file:

function GrdInit() 
{ 
    var myGrid = getCont("grdTest"); 
    myGrid.jqGrid('hideCol', 'cb'); 
}
Sorce answered 21/2, 2012 at 16:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.