Page 1 of 1

Bind Grid Column Amount

Posted: Thu May 20, 2021 8:57 am
by JayGoo83
How come we cannot bind the amount of columns to a value in our RPG program? I would like to create tables that only show columns if set up in a parent file.
The basic gist is that a parent record can be set up with optional extra fields. The child record would then show inputs for each of the extra fields. If the parent isn't set up for the extra field than we don't give the option in the child when adding new. That part I got. But I would like have the grid showing all the children follow same logic.
I feel like I could probably create a bunch of grids with visibility bounded value, stack them on top of each other, and then toggle which view to see. But that seems sloppy, at least from a visual design POV.

Thanks in advance.

Re: Bind Grid Column Amount

Posted: Thu May 20, 2021 12:38 pm
by Scott Klement
Not sure why the number of columns isn't bindable. I suspect its because it'd do things like wipe out the widgets and field bindings for the columns if they were removed, and that'd cause problems at run-time. But, alas, this is just a guess.

Some customers have done similar tasks to yours using some JavaScript code. In the onload event of the screen, they call the hideColumn API to hide (rather than remove) the columns that they don't want to be displayed. For example, you could have an output field that has visibility=hidden that contains the number of columns you want to show, and the onload event could loop through and hide the extra columns based on that number.

Another alternative that I've seen used is to hide the entire grid. Then use an HTML Container widget (or similar) to draw their own grid using HTML code. The HTML Container supports EJS templating, so that can be very powerful. Obviously this requires more code and stronger web development skills.