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?

3 Answers 3

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();
5
  • This is the best way I've found to do this.
    – Dave
    Jun 18, 2011 at 18:18
  • What if the target list does not has an id? Apr 3, 2013 at 13:15
  • @AmirAliAkbari: I don't understand your question. What "target list" you mean?
    – Oleg
    Apr 3, 2013 at 13:53
  • @Oleg I meant converting a table with no id (<table class="x">) to a jqgrid, but apparently jqgrid requires the <table> to have an id. Apr 4, 2013 at 4:37
  • 1
    @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.
    – Oleg
    Apr 4, 2013 at 8:51
0

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

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'); 
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.