Page 1 of 1

Hide columns

Posted: Wed Oct 26, 2016 2:35 pm
by JHMComp
I know you can make a column not visible while you're creating the grid, but is there a way to hide one after it's created using javascript or ajax?

Re: Hide columns

Posted: Mon Oct 31, 2016 8:45 pm
by jomitech
You can use Ajax to set the Visible property on the column to false.

Re: Hide columns

Posted: Tue Nov 08, 2016 10:34 am
by JHMComp
I believe that I'm on version 11, if this works better in a newer version then I'll upgrade. Here's my issue.

I found a way to hide columns but only by modifying jtplatinumgrid.inc.php. I'm fine with that.

But even with an unmodified jtplatinumgrid.inc.php there is an issue with master-detail grids. I added 5 columns to your master grid sample. When they're all visible the master row looks the same after clicking the + to expand. But if you hide those 5 columns and click the +, the master row gets smaller and shifts to the left like the hidden columns are taking up space in the row. The more hidden columns, the more the visible ones are pushed to the left.

edit: Sorry, named the files wrong but you can see the difference.

Re: Hide columns

Posted: Fri Nov 11, 2016 5:37 pm
by jomitech
What modifications did you make to jtplatinumgrid.inc.php? Didn't setting Visible to false on the column work?

Re: Hide columns

Posted: Mon Nov 14, 2016 12:45 pm
by JHMComp
Setting visible didn't work, once the grid was loaded I couldn't change anything (visibility, caption, etc) on refresh, only the data would change.

I'm loading the page with restore_session=1 and that might have something to do with it. I added a flag to the init function to prevent this line from executing during a refresh: $this->unserialize();

That seemed to fix it but I still have the master-detail problem even without that change.

Re: Hide columns

Posted: Sat Nov 19, 2016 10:51 am
by jomitech
Only load the page with ?restore_session=1 the first time. For any subsequent refresh/load, remove that parameter so that the information can be pulled from the session.

You're correct about Visible. If it's false, the column is not available on the client at all. You would have to do an Ajax or page refresh to get the column back again.

For the column widths, have you tried setting explicit width values on the columns?

Re: Hide columns

Posted: Mon Nov 28, 2016 1:18 pm
by JHMComp
I just tried setting widths, it uses them until you click the + to show the detail grid, then it ignores them and makes them all smaller.

Re: Hide columns

Posted: Fri Dec 02, 2016 10:16 am
by JHMComp
Actually, I was wrong on that, it does use widths if you specify them. I should be able to get it working now. Thanks.