1. Hannu Pikkarainen
  2. PowerBuilder
  3. Friday, 6 October 2023 09:30 AM UTC

Hi,

Is it possible to change order of columns i a grid-datawindow (to move unnecessary columns to the end of grid) dynamically with code on runtime?

Moving them visually would not be good enough, it should also affect the order of columns when importing data to datawindow from file or clipboad.

BR, Hannu

Accepted Answer
Hannu Pikkarainen Accepted Answer Pending Moderation
  1. Sunday, 19 November 2023 12:59 PM UTC
  2. PowerBuilder
  3. # Permalink
Yes, exactly. So is there a way to change dynamically the column order in the select statement?
Comment
There are no comments made yet.
Markus Eckert Accepted Answer Pending Moderation
  1. Tuesday, 21 November 2023 09:00 AM UTC
  2. PowerBuilder
  3. # 1

Hi Hannu

I think it might be worth it for you to look into the SyntaxFromSQL Function. SyntaxFromSQL - - PowerScript Reference (appeon.com)

Unfortunately I don't have any experience on how much visual customization is possible, but it does cover the visual as well as the data column ordering.

Regards,
Markus

Comment
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Friday, 6 October 2023 15:03 PM UTC
  2. PowerBuilder
  3. # 2

Hi Hannu;

  Suggestion:  My STD Framework allows the App User to drag, resize, etc the Grid DWO columns around any way they need them and it then remembers where the App user did to the GUI layer & restores the Grid GUI when the DWO is re-instantiated again - even after an App restart. However, it does not alter the SQL and thus the internal result set is unchanged but only the presentation layer is affected ...

Original DWO ...

App User Rearranges Grid DWO (as an example) ....

After an App User Restarts the App (or just reopens the Grid DWO again) - from that point onward ...

  What about using that approach?

Regards ... Chris

Comment
  1. mike S
  2. Sunday, 19 November 2023 15:58 PM UTC
"Moving them visually would not be good enough, it should also affect the order of columns when importing data to datawindow from file or clipboad."



that won't handle imports (importstring/importfile). handles clipboard and display
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 6 October 2023 13:34 PM UTC
  2. PowerBuilder
  3. # 3

Hi, Hannu -

I suggest you edit the source of a DataWindow that uses a SELECT statement as its data source, and closely examine the source syntax.

Near the top, after some overall properties are defined, are the band properties, followed by the table/column definitions. These are defined in the order that the values are expected to be obtained from the data source (a SELECT statement or a stored procedure).

Included in the table/column definition section comes the retrieve definiton (the PBSELECT or SELECT statement (or stored procedure call).

Next are the various DWObjects (column objects, text objects, lines, etc.) that make up the visual presentation in the order in which they are drawn/rendered. Each column object definition references an ID, which identifies which column definition is associated (1 = the first column definition, 2 = the second, etc.) with each column object.

To be able to successfully change the order of the columns returned by the SELECT statement, all of the following would need to be changed:

1. The SELECT statement.
2. The ordering of the list of column definitions.
3. The ID's referenced by the column objects.

This is what the DataWindow Painter does for you. There is (currently) no programmatic way to dynamically alter this, other than by creating/supplying new syntax for the entire DataWindow. This can be and is done. Of course, you could develop this functionality on your own, essentially duplicating the syntax-creation portion of what the DW Painter does.

Best regards, John

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Friday, 6 October 2023 09:53 AM UTC
  2. PowerBuilder
  3. # 4

Hi.

The column order in the datawindow designer (ordering in grid) doesn't affect the way files are imported. It's the order of columns in the select statement (and the order in column specification in case of external datawindows).

Andreas.

Comment
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.