Issue on hiding or showing columns

QuestionsIssue on hiding or showing columns
Massimo Gagliardi asked 5 years ago

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

1 Answers
Abu Ghufran answered 5 years ago

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.

Your Answer

15 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?