1. Bjarne Anker
  2. PowerBuilder
  3. Tuesday, 20 November 2018 19:24 PM UTC

Hi.

 

So, I have a freeform datawindow with several columns.

Our customers wants us to add functionality to show/hide certain columns and save the setup.

The saving part is easy, and the show/hide as well using dw_data.modify("col.visible='<0 or 1>').

The datawindow has about 26-28 columns in total, and for now I've added the possibility to show/hide 8 of them.

 

But the big issue is how to move the remaining visible columns to fill all the gaps where the columns which are hidden used to be.

Is there an easy way to do this, perhaps in Powerscript, PFC or some other smart custom function?

Even better if it's rather generic and can be used on other datawindows in the future.

 

I know that grid layout is handling this automatically, but we dont want to use the grid layout for now.

 

Best regards,

 

Bjarne Anker

Maritech Systems AS

Molde - Norway

Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 21 November 2018 14:55 PM UTC
  2. PowerBuilder
  3. # 1

Hi Bjarne Anker,

 

Why don't you want to use Grid?

You can construct your dw as tabular/freeform 

Once finished you edit the source code and set processing=1 (instead of 0). (as long as it has only one column below the header).

You can make the grid "look like a tabular" dw:

- display off

- no mouse select 

- no gridlines

it would then automatically fills up the spaces when you set columns (and labels) to not visible.

(See attached test app).

Attachments (1)
Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Wednesday, 21 November 2018 11:17 AM UTC
  2. PowerBuilder
  3. # 2

Just an idea, have not tried it myself, since we do use GRID dw's.

The fact that you mention GRID dw, makes me think that a Tabular dw would do. You don't need it to be freeform?

(Anyway, both are processing=0)

 

If so:

Has anyone tried this way of doing it?

To save the new visible state of the columns without gaps:

- temporarily make the dw of typ GRID (processing=1)

- then make the dw tabular again (processing=0)

 

Not sure if you would have to do an intermediate step like doing a setredraw() for the dw or setting the columns to "moveable" or something similar.

 

 

Comment
  1. René Ullrich
  2. Wednesday, 21 November 2018 12:51 PM UTC
You can't modify the processing property at runtime. :-(
  1. Helpful
  1. Miguel Leeuwe
  2. Wednesday, 21 November 2018 14:49 PM UTC
Yes your absolutely right. I said it because in the past I've used it ( setting processing to 1) to be able to manipulate / get object properties of a dddw or nested dddw (something like that). The trick was to make PB "think" that the dwChild was of type Grid and that way I could get the properties.

The Modify of processing does not return any error, but it simply doesn't show as a grid.
  1. Helpful
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Wednesday, 21 November 2018 07:01 AM UTC
  2. PowerBuilder
  3. # 3

Exactly what I’m doing now also.

it looks like the only solution if you want it to look nice.

 

Perhaps you have some sample code to share?

In case I’m over complicating things :)

 

Regards,

 

Bjarne

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Wednesday, 21 November 2018 05:11 AM UTC
  2. PowerBuilder
  3. # 4

Every time that I've had to do this I ended up writing an "of_move_columns()" function and hardcoding the values based on calculating where thecvisible columns would need to be.

The actual determination is made in a CASE statement that tells me which columns have been hidden; which lets me know just how far the visible columns have to be moved.

It's tedious but simple to do. And it works every time.


Olan

 

Comment
There are no comments made yet.
Bjarne Anker Accepted Answer Pending Moderation
  1. Tuesday, 20 November 2018 20:52 PM UTC
  2. PowerBuilder
  3. # 5

Hi.

 

I tried the slide left option, but the column did not slide when I modified the one to the left with dw_data.modify("colA.visible = '0'").

Is there anything else I have to code in order to make slide left to work?

The datawindow is luckily read only.

 

Regards,

 

Bjarne

Comment
  1. Ashutosh Varshney
  2. Tuesday, 20 November 2018 21:49 PM UTC
Try setting the width & height to 0 as well.
  1. Helpful
There are no comments made yet.
Ashutosh Varshney Accepted Answer Pending Moderation
  1. Tuesday, 20 November 2018 20:24 PM UTC
  2. PowerBuilder
  3. # 6

Bjarne,

You can use the Slide Up and Slide Left properties to fill those empty spaces.

Hope this helps.

Comment
  1. Chris Pollach @Appeon
  2. Tuesday, 20 November 2018 20:45 PM UTC
Hi Bjarne;

FWIW: This might be OK if the DWO is "read only". However, sliding columns where data entry is required - can end up being a GUI mess. So it all depends how Ashutosh is using the DW in the App.

Regards ... Chris
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.