I have a sub-grid in which I add or edit records via the line-in function
For the addition of a record I use, in the first column, a radiobox by which I can show or hide some columns.
I use the standard jqGrid ("hideCol") and jqGrid ("showCol").
In the face of each hidden column monster another column of the same size.
Unfortunately, this mode reduces or enlarges the grid that does not fill the window anymore.
Can anything be done?
These are the grid options:
$grid["width"] = NULL;
$grid["autowidth"] = true;
$grid["autoresize"] = false;
$grid["shrinkToFit"] = true;
$grid["forceFit"] = true;
This is the code fragment:
function radioOn(t) {
$("#list2 input[name='Tipo']").val(t);
if (t==1) {
$("#list2").jqGrid("showCol","IDArticolo");
$("#list2").jqGrid("hideCol","Descrizione");
$("#list2").jqGrid("hideCol","IDMateriale");
}
else if (t==2) {
$("#list2").jqGrid("showCol","IDMateriale");
$("#list2").jqGrid("hideCol","IDArticolo");
$("#list2").jqGrid("hideCol","Descrizione");
}
else if (t==3) {
$("#list2").jqGrid("showCol","Descrizione");
$("#list2").jqGrid("hideCol","IDMateriale");
$("#list2").jqGrid("hideCol","IDArticolo");
}
}
Here the initial screenshoot:
http://easycaptures.com/fs/uploaded/815/7956645820.png
and here the final:
http://easycaptures.com/fs/uploaded/815/7451139910.png
You can remove …
$grid["autoresize"] = false;
$grid["shrinkToFit"] = true;
$grid["forceFit"] = true;
And have JS code with each radio click.
var newWidth = jQuery(window).width() * 0.975;
jQuery("#list1').jqGrid("setGridWidth", newWidth);
where list1 is grid id. You can adjust 0.975 to desired value.
Demo: http://pastebin.com/eq00HxUh, click on window anywhere to hide cols.