1. Mike Kolenda
  2. PowerBuilder
  3. Monday, 21 December 2020 14:17 PM UTC

Is there a tool or a recommended sequence of steps to take a grid DW with mismatching columns and return it to a state where like fields and headers are in the same column?

Over the years customizations of grids have made our DWs appearing unruly internally (See Disrupted_Example.png) and may appear mismatched when displayed to the user at runtime. I'd like to be able to resolve this with code (outside the painter or edit source). I've been trying accomplish this feat with a utility but I have had limited success.  Any suggestions on how to consistently resolve this?

There preferred outcome would be like the image DW_Realigned.png.

 

Attachments (2)
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Friday, 25 December 2020 20:31 PM UTC
  2. PowerBuilder
  3. # 1

You could do something like this with a  small application maybe or manually:

1. Export the dwsyntax to a file.

2. In the exported code you replace "processing=1" with "processing=0 (this will make the dw tabular instead of grid)

3. You then search in the exported code for each column's static text field (nameOfColumn + "_t" if you're lucky) and replace the x and width attributes' values of the text object to be the same as the values for the corresponding column object.

4. You then import the exported code into the pbl, and save it (you'll have to do a minimal manual change to be able to save, like moving a text one 'tick to the right and then back to the left for example).

5. you export the saved dw again

6. In the exported code you replace "processing=0" with "processing=1 (this will make the dw grid instead of tabular).

 

I'm not sure if step 4 and 5 would be really necessary and if maybe you can go directly to step 6 by editing the source code.

regards

 

Comment
  1. Miguel Leeuwe
  2. Friday, 25 December 2020 20:38 PM UTC
You can use LibraryExport() to write the dw to disk then manipulate it using string functions and when finished import the changed file with the modified syntax, using and LibraryImport().
  1. Helpful
  1. Mike Kolenda
  2. Monday, 4 January 2021 14:31 PM UTC
Thanks, Miguel. I have couple follow-up questions, because the routine I've been using is relatively the same as yours and I've seen different behaviors when switching processing from tabular (0) back to grid (1).



I'm looking to do this with an EXE as opposed to changing the export file manually. Instead of exporting the file I've been manipulating the DW with the Modify command. As you have mentioned in steps 2 & 6, I've found that changing the DWs type before adjust the columns allows for them to be realigned. But upon switching back to grid it doesn't always take (gridlines do not appear) I've attempt to adjust the property "dataWindow.grid.lines=0" but it doesn't seem to change the results.



Can the same result be had without exporting the DW source?



BTW - I am lucky (Ref Step 3). The text fields do match nameOfColumn + "_t".



Regards

  1. Helpful
  1. Miguel Leeuwe
  2. Monday, 4 January 2021 15:27 PM UTC
Hi Mike,

It's difficult to answer these questions without having an exported dw and your code.

With "switching back to grid ", you mean that you do a modify() of the processing back to have a value of 1?

So... do I understand well that you want to leave the dw "as is" and simply modify the positions always before using them in the code?

A few things that come into my mind:

1. Make sure that the first line of source code with the version information is correct. When you migrate your application to a higher powerbuilder version, that information is not modfied until you do some change. For example, I still have datawindows in 2017 and 2019 which show "release 12.6;"

2. Try setting "grid.lines=1" (=off) first, then "grid.columnmove=yes" and then "grid.lines=0" (=on). ( BTW: I don't know why 0 is the value for 'on' and 1 the value for 'off' and 2 for 'display only'. It doesn't make sense at all, but I guess it's too late to change it after all these years of powerbuilder).

3. Doing everything from code, you might have to set more attributes than just the "x" and "widths", you probably also have to set the tabsequences in order from left to right and make sure there's a tiny gap between the columns and also the text labels. (haven't tried this, just comes to mind).



The advantage of doing an "import" using the IDE, is that the attributes will be automatically adjusted, event if there's (big) gaps between the columns.

I have some code where I let users make columns visible or not. What I do when they make a column visible, is add the column with a very high X value (so it shows as the most right column on the datawindow). Since it's a grid, the datawindow will automatically adjust it to the correct x value after making the column visible. PFC's will then automatically grab the correct values when I close the window.

Hope it's any good,

regards
  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.