0

Am using Jqgrid MultiSelect Option.

it worked perfectly. Is it possible to have that property set dynamically ?

For example : I click on a button then the multi Select property should be enabled until that that should not be shown to user.

How do i implement this in JqGrid ?

Thanks

user2067567
  • 3,695
  • 15
  • 49
  • 77

3 Answers3

2

jqGrid don't support creating of columns dynamically. So you can't switch on multiselect: true option without recreating of the grid (see the answer).

If you ready for experiments you can follow my suggestions from the answer which do describe how one could implement the feature with some restrictions.

UPDATED: My previous answer is old. If you use jQuery version 1.8 or higher you have to change the line events = $grid.data("events"); to events = $._data($grid[0], "events"); to subclass reloadGrid event. See fixed demo here.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
0

You can use this bit of code:

   var myGrid = $("#grid_name");
   $("#cb_"+myGrid[0].id).hide();

and to show it

   var myGrid = $("#grid_name");
   $("#cb_"+myGrid[0].id).show();

if you want to hide all the checkboxes for each row:

   $("input[name^='jqg_']").each(function() {
       $(this).hide();
   });

and show it:

   $("input[name^='jqg_']").each(function() {
       $(this).show();
   });

I've prepared a fiddle for you.
Hope it helps.

LeftyX
  • 35,328
  • 21
  • 132
  • 193
  • my question was ab the Entire CheckBox Column not only the Header part ! Thanks for your fiddle – user2067567 Jun 24 '13 at 11:06
  • @LeftyX: Hiding of chechboxes don't change the multiselect behavior of jqGrid. If you click on one row and then on another one you will still have multiselect behavior. You have to change value of `multiselect` option of jqGrid to have single-select style. If you click on "Reload Grid" button of the navigator bar, sort the column or change the page number (click on next page) you will see initial `multiselect: true` grid. So one have to do a little more. – Oleg Jun 24 '13 at 12:50
  • @Oleg: I agree Oleg. The question wasn't that clear at the beginning. – LeftyX Jun 24 '13 at 13:42
0

yes you can do like this

if(true)
    $("#GridID").jqGrid('setGridParam',{multiselect:true}); 
else
    $("#GridID").jqGrid('setGridParam',{multiselect:false}); 
Manish Parmar
  • 859
  • 1
  • 11
  • 19