Hide columns

PlatinumGrid - Full version
Post Reply
JHMComp
Posts: 5
Joined: Wed Oct 26, 2016 10:52 am

Hide columns

Post by JHMComp » Wed Oct 26, 2016 2:35 pm

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?

jomitech
Site Admin
Posts: 1967
Joined: Wed Oct 08, 2008 12:23 am

Re: Hide columns

Post by jomitech » Mon Oct 31, 2016 8:45 pm

You can use Ajax to set the Visible property on the column to false.
Jon

JHMComp
Posts: 5
Joined: Wed Oct 26, 2016 10:52 am

Re: Hide columns

Post by JHMComp » Tue Nov 08, 2016 10:34 am

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.
Attachments
expanded.png
(23.17 KiB) Downloaded 231 times
closed.png
(41.28 KiB) Downloaded 225 times

jomitech
Site Admin
Posts: 1967
Joined: Wed Oct 08, 2008 12:23 am

Re: Hide columns

Post by jomitech » Fri Nov 11, 2016 5:37 pm

What modifications did you make to jtplatinumgrid.inc.php? Didn't setting Visible to false on the column work?
Jon

JHMComp
Posts: 5
Joined: Wed Oct 26, 2016 10:52 am

Re: Hide columns

Post by JHMComp » Mon Nov 14, 2016 12:45 pm

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.

jomitech
Site Admin
Posts: 1967
Joined: Wed Oct 08, 2008 12:23 am

Re: Hide columns

Post by jomitech » Sat Nov 19, 2016 10:51 am

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?
Jon

JHMComp
Posts: 5
Joined: Wed Oct 26, 2016 10:52 am

Re: Hide columns

Post by JHMComp » Mon Nov 28, 2016 1:18 pm

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.

JHMComp
Posts: 5
Joined: Wed Oct 26, 2016 10:52 am

Re: Hide columns

Post by JHMComp » Fri Dec 02, 2016 10:16 am

Actually, I was wrong on that, it does use widths if you specify them. I should be able to get it working now. Thanks.

Post Reply