Page 1 of 1

Adding columns to grid widget

Posted: Fri Dec 05, 2014 2:03 pm
by ndeppe
I'm working on a program in Profound UI in which we want the users to be able to show/hide columns in a grid. They would choose which columns they want to see, and this should be saved for the next time the user opens the program. I'm having a hard time figuring out how to implement this. In looking at the Javascript API, I found there is a method removeColumn which removes a column from a grid, but I can't find anything to add a column. I could also implement this by adding all available columns to the grid, but then hiding the columns the user doesn't want to see instead of completely removing it. I would then need to be able to make a column visible if the user decides he/she wants to see it.

Any thoughts on this?

Re: Adding columns to grid widget

Posted: Fri Dec 05, 2014 3:50 pm
by Scott Klement
How are you going to get the data into the columns if you add them on-the-fly? You can't change the record format in the RPG application on-the-fly to add/remove fields, that has to be known at compile-time.

So I would suggest that you should output all columns. Then, the display file can potentially call the removeColumn() API that you mentioned to remove anything that's unwanted when displaying the data to the user.

Re: Adding columns to grid widget

Posted: Fri Dec 05, 2014 5:06 pm
by ndeppe
Hi Scott,

My initial thought was I would have to define all of the fields on the subfile, but it would be a matter of removing and adding column. Other than that, I could simply hide/display the columns as necessary, but there doesn't seem to be methods for hiding columns in the API.

Basically, this is what I'm looking to do: The grid displays all available columns initially. A user clicks a button and a window that lists all available columns pops up. The user can check/uncheck the columns and press OK. Any column that was unchecked would be removed and any column that was checked would be displayed. These settings would then be saved for the next time the user opened the program.

I can use the removeColumn method to remove columns that the user unchecks, but I'm wondering how to handle the case when a user checks a previously unchecked column.

Re: Adding columns to grid widget

Posted: Fri Dec 05, 2014 6:39 pm
by Scott Klement
What I would do is send the screen back to the RPG program -- then have the RPG re-display the screen. This will reset it back to all columns being shown. Then, you can re-remove the unwanted ones.

Re: Adding columns to grid widget

Posted: Fri Dec 05, 2014 6:45 pm
by ndeppe
That makes sense. I'll give it a try. Thanks, Scott!

Re: Adding columns to grid widget

Posted: Mon Dec 08, 2014 1:49 pm
by SeanTyree
Another option would be instead of removing the columns, make them 0 width. This could even possibly be stored through the persist state property.

Sean

Re: Adding columns to grid widget

Posted: Mon Dec 08, 2014 8:43 pm
by Scott Klement
Let us know which way works out the best for you. I haven't done much experimenting with this stuff, so it'll be good to know what customers find works the best.

Re: Adding columns to grid widget

Posted: Tue Dec 09, 2014 7:13 pm
by ndeppe
I haven't gotten a chance to play around with it too much as other priorities have come up. I did test out the removeColumn method but ran into a snag. The problem is I'm allowing the users to rearrange columns (moveable columns property on the grid), so the column can be in any position. The removeColumn method removes column by its index at runtime and not the index at design time. I think the way I would have to get around this is by using some Javascript magic and determine the column positions at runtime by going through each header element and checking the header text. I can then map the header text to column position in order to determine which columns to remove. That seems like a clunky way of doing it, but I can't think of a way around it.

This sounds like a cool enhancement request for PUI. It would be nice if this functionality was built in. For instance, grids can have a property to allow users to select columns (much like the properties to allow users to resize columns and reposition columns). The users would be able to right-click on the header and choose "Select Columns..." (much like the export to CSV functionality). The users would then be able to select the columns to display. This would be "persistent" like column positions and widths. Just a thought. Maybe I'll submit a request for this for the future.

Re: Adding columns to grid widget

Posted: Wed Dec 10, 2014 6:46 pm
by Scott Klement
The best way to submit a feature request is to e-mail it to support@profoundlogic.com

Re: Adding columns to grid widget

Posted: Wed Feb 07, 2024 10:02 am
by Marcellus
ndeppe wrote: Fri Dec 05, 2014 2:03 pm I'm working on a program in Profound UI in which we want the users to be able to show/hide columns in a grid. They would choose which columns they want to see, and this should be saved for the next time the user opens the program. I'm having a hard time figuring out how to implement this. In looking at the Javascript API, I found there is a method removeColumn which removes a column from a grid, but I can't find anything to add a column. I could also implement this by adding all available columns to the grid, but then hiding the columns the user doesn't want to see instead of completely removing it. I would then need to be able to make a column visible if the user decides he/she wants to see it.

Any thoughts on this?
To implement dynamic column visibility in Profound UI, preload all available columns and then selectively hide or expose them based on user preferences. Using methods to change column visibility rather than adding/removing columns dynamically can make the implementation process easier. Further investigation of the Javascript API, or requesting assistance from Profound UI resources, may yield additional insights.