1. mike S
  2. PowerBuilder
  3. Wednesday, 19 May 2021 17:03 PM UTC

allowing a user to move/resize columns is the main (only?) reason to use a grid dw.

users EXPECT the system to remember their grid settings, and also expect a way to restore the original layout.  pretty much a standard of software since the mid 90s.

 

PB datawindow settings of a grid are complete garbage.  Set the x and width of a grid field and sometimes it works and often it doesnt'.     

Use the visible property to hide everything and then turn it back on works much better, but you have to restore the visible property AND expression in case you had an expression.  The PFC uses this method to sort of restore the grid field positions (it mostly works).  

BUT - if you have a compute field in the footer of the grid and that field has a visible expression on it, then it stays invisible if you use the visible setting method of column restores.  This is a known bug, never fixed.  Regardless, this is only an issue because setting the X value method DOES NOT WORK.  The kicker is that powerserver 2020 and prior versions works properly with the visible setting.  I assume it won't in PS2021. 

 

setting the x value of a grid should work.  period. end of story.  but it doesn't.  I'm tired of revisiting these same bugs over and over and over again.

Long time ago it was recommend on the old forums to simply not use a grid datawindow because of these problems.  Instead it was recommended to build your own grid like datawindow using lines and then do a lot of powerscript to get it to work like a grid.  Has anyone done this, and is it worth doing?

the other option might be to rebuild the syntax of the datawindow at run time rather than do a bunch of modifies.  That also is a lot of work, but may in fact be the only answer.

I know several applications just use the brute force approach and store the entire datawindow just to save the grid positions, but that seems like so much overkill to get around unfixed bugs.  Plus you would also have to manage any changes to the datawindow in new versions of your system.

 

Matt Balent Accepted Answer Pending Moderation
  1. Wednesday, 19 May 2021 23:28 PM UTC
  2. PowerBuilder
  3. # 1

I wrote a grid service to address these things back in 2001.  It saves user changed grids for column order, size, and visibility.  It's on my anvil-of-time.com site if interested.  The best update to girds I can think of since then is the 'autosize width' feature put in in 12.5 or 12.6.  That eliminated a large chunk of code I had been using (I think originally taken from Roland Smith's website/examples).  My biggest complaint on grids is no control over the line properties and the highlighting.

 

...my .02

Comment
  1. mike S
  2. Thursday, 20 May 2021 12:42 PM UTC
How do you apply the changes? If you use modify to apply the changes then you hit the visible bug in the datawindow footer, and if you change the order using the .x setting then it only often works. using modify has problems and i've gone through every combination of .x/visible in loops, multiple times, etc. over many versions of pb including powerserver.



I think the only way to get it to work completely is to parse the entire datawindow and either rewrite the syntax at runtime or change processing styles twice.. i think that will be too slow. determining all fields that share the same column will be slow regardless.



or abandon the grid entirely and build my own. that gets away from all the other unsolved problems in the grid, but is a lot of work to refactor into my application assuming it works well enough. I'd love to know if anyone has built their own grid that functions well.









  1. Helpful
There are no comments made yet.
Brage Mogstad Accepted Answer Pending Moderation
  1. Friday, 1 September 2023 10:26 AM UTC
  2. PowerBuilder
  3. # 2

Mike,
Boils IMO down to storing/getting syntax in 3 main operations:
1. Always store syntax of dw in db in close event
dw_moddwo.Describe("DataWindow.Syntax")

2. Always use syntax of grid dwo  "as is" from your main source in events of change of user,version,PBD/DLL. 
You'll need a system/tables to manage this - always check on window.ClassName,dataobject,userid,version (of exe),date of PBD/DLL before applying syntax

3. If no changes according to step 2, always use stored dwsyntax from db if its there.
Get and apply syntax from db
ll_ret = dw_moddwo.Create(dwsyntax, ls_errors)

pbm_ithinkthiswillwork
Brage

Comment
  1. Miguel Leeuwe
  2. Friday, 1 September 2023 10:32 AM UTC
Nice one Brage!

But the problem with your point 2, is that users might absolutely not like it to get a full reset of all of the modifications they might have done. We have hundreds of datawindows with hundreds of possibly visible, resized, moved, etc. columns.

Other than that, it's a geat suggestion.

regards.
  1. Helpful
  1. Brage Mogstad
  2. Friday, 1 September 2023 10:48 AM UTC
Thanks Miguel,

Appreciate the love. And you ha a good point if updates are release in short intervals.

Hmm, well, perhaps do a match on the source and only apply changes to those windows who are modified in new version.

That way, changes should not occur too often for users to - should not get overly grumpy unless you are constantly releasing new versions of dwos.

I'd definately recommend a varsion control table and db as backend on this, that way hundreds of dwos with hundreds of possibilities will never become a problem and you do not need a lot of coding as the excellent ease of dwo control and where clauses will solve that issue for you.



Mvh

Brage



  1. Helpful 1
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 19 May 2021 18:03 PM UTC
  2. PowerBuilder
  3. # 3

Hi Mike;

   You make some great points! Please open a Support Ticket for this enhancement so that Appeon can get this into the queue- hopefully for PB2022.

  In the mean-time, I feel an STD Integrated Framework enhancement coming to a theater near you soon.   ;-)

Regards ... Chris

Comment
  1. Chris Pollach @Appeon
  2. Monday, 7 June 2021 21:27 PM UTC
Hi Everyone;

FYI: I now have working prototype code in my STD Framework that performs a full Grid DWO save/restore between Open/Close and App restarts. This preserves *all* the grid column locations, grid line sizes, fonts, filters, sorts, etc as per *all* the App user's mouse actions against the DWO.

I did all this in two basic lines of code - but of course, it will need more to properly implement a robust feature - but I know know that it's possible, simple, foolproof (I hope - LOL), etc to implement . ;-)

I hope to release this in the next STD Framework beta for PB/PS2021 beta very soon. he hardest part will be System-To-System controls and also to fallback to the original DWO if required. ;-)

Regards ... Chris
  1. Helpful
  1. Kalpana Arumugham
  2. Wednesday, 26 July 2023 15:38 PM UTC
Is this available to use Chris ?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 26 July 2023 18:40 PM UTC
Hi Kalpana ;

Yes, this feature was released in the 2021.4.0.258 Major Release (2021R4) version of the framework! :-)

FYI: http://chrispollach.blogspot.com/search?q=2021R4

HTH

Regards ... Chris
  1. Helpful
There are no comments made yet.
alessandro feltrin Accepted Answer Pending Moderation
  1. Friday, 21 May 2021 06:05 AM UTC
  2. PowerBuilder
  3. # 4

Hello Mike.

I also find myself in the same situation. I spend more time getting the GRIDs working than developing software that uses the same grids. I'd like to worry about other things and not making the grid data window work in a "modern" way. I understand that touching Xs in a grid is taboo. I realized that to make the odd and even colored lines I have to make them. I understand that I also have to manage to highlight the selected field in a datawindow. I understand that we developers can do it all by ourselves. I also realized that someone did something. The only thing I didn't understand is whether APPEON wants to make these blessed grids FULLY and REALLY modern or not. So, just to get an idea.
PS. Remember that to manage these implementations, it means that the performance of the datawindows slows down during the creation phase. Then if you have a single program with 20 datawindows ....

have a nice day and I hope someone reads these posts!

Comment
There are no comments made yet.
Ronnie Po Accepted Answer Pending Moderation
  1. Friday, 21 May 2021 15:59 PM UTC
  2. PowerBuilder
  3. # 5

Another problem is that text objects in the header band don't always line up with their corresponding column controls in the detail band, making things look randomly inconsistent from column to column.

This may not work for your situation, but what I ended up doing to save the user's grid settings was to capture the size and positions of the text controls in the header band (they are named so that I can derive the columns that they belong with). I saved the values in the database, tied to the specific user and DW, but you could also use the registry. Next time the user opens the same grid, I create() the entire DW from scratch using template syntax in which I plug in the values of x and width for each control. As you noted, modify() doesn't work reliably.

Comment
  1. mike S
  2. Monday, 7 June 2021 18:44 PM UTC
yeah, i can't guarantee that all my headers (text, computes) have naming convention. i also have footer/trailer objects (subtotals) and possibly multiple headers, so thats a lot of renaming. (I support grid reports having this functionality).



this might be the most thorough approach , would just need to figure out a way to group everything in a column which is a lot of scripting.
  1. Helpful
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Monday, 7 June 2021 18:54 PM UTC
  2. PowerBuilder
  3. # 6

I added code to move all the columns to the back first (columns get move past the last column in order from left to right), then move the columns to the front (first column gets moved in front of all columns).  So two loops that change the x value but going in different direction.

this seems to work (several reproducible examples now are fixed), and it is somewhat similar in concept to the visible technique.  Originally i just set first columns to front only, which worked about 95% of the time.  Then tried to only move the columns to the back, which maybe worked about 70%.  doing both of them seems to work 100%. 

This is probably faster than the visible technique.  At some point i may test with powerserver 2020 to see if it works there too (visible technique works in PB too but it has a bug that hides footer/trailer computes, PS2020 does not have that bug).

 

 

Comment
There are no comments made yet.
Miguel Leeuwe Accepted Answer Pending Moderation
  1. Thursday, 27 July 2023 05:04 AM UTC
  2. PowerBuilder
  3. # 7

I cannot access my code right now, but we do something like this:

1. Store all of the column names and computed field names and its x and width values in the database.

2. When restoring, I put all of these stored values in a datastore which is sorted by x position

3. loop through all rows of the datastore and for each one, do a modify of the width and also of the x, but for the x value, I'm not using the value that's been stored. Instead I set it to a ridiculously high value, to make sure it'll appear as the most right column. Then go on to the second lowest x value on the datastore (second loop and second row). Do the same thing for all rows. In the end, all of the columns will end up being in the correct order. As you know, when assigning modifying to a very high x value, that will assure that the column will be most right, but it will always be positioned right after the previous column with grids. (so it wouldn't really end up having the "ridiculously high value").

If I'm not mistaken, you only have to modify the positions of what's in the detail band, the headers will automatically be adapted when they move.

After having looped through all of the columns, you might have to do a SetRedraw(True), but I'm not sure of that.

regards,

MiguelL

Comment
There are no comments made yet.
Brage Mogstad Accepted Answer Pending Moderation
  1. Thursday, 24 August 2023 19:57 PM UTC
  2. PowerBuilder
  3. # 8

Hello,

Perhaps you can use this.

You could store dwo & dwsyntax per user in the db and use crete & Library import ONLY if your customers environment and your deployment & setup 

allows modifiying files per user on separate client pc.

lds_moddwo.dataobject = ls_objectname
dwsyntax = dw_data.GetItemString(ll_rader[ll_row],"dwsyntax")
if isnull(dwsyntax) then dwsyntax = ""
if len(trim(dwsyntax)) > 0 then
//test syntax with create
ll_ret = lds_moddwo.Create(dwsyntax, ls_errors)
if ll_ret > 0 then
//change sourcecode in pbd file according to customers needs

rtncode = LibraryImport(ls_pbl,ls_objectname, ImportDataWindow!, dwsyntax, ErrorBuffer )

if rtncode <> 1 then
//logg error
of_loggerror(ls_objectname,"En feil har oppstått." + string(rtncode) + " " + ErrorBuffer)
else
//change modified date on dwo, and syntax in db etc...
ls_dwostrtest = LibraryExport ( ls_pbl, ls_objectname, ExportDataWindow!)
ll_ret = dw_data.SetItem(ll_rader[ll_row], "modified",string(datetime(date(today()),now())))
end if
else

 

Regards

Brage

Comment
There are no comments made yet.
mike S Accepted Answer Pending Moderation
  1. Friday, 1 September 2023 13:54 PM UTC
  2. PowerBuilder
  3. # 9

the main issue for me is that the technique that i use (setting visible property on/off) ran into the old PB bug:  Track Bugs | Appeon

which has been fixed in 22R2.  Since PS and PB are the same runtime now, it finally works in both using the same technique.  

 

The nice thing with this approach is that if the datawindow is changed at all, the grid restore still works (in that the user's preferences are still set.)

It is still stupid that changing the x property doesn't actually move things around correctly, but the required functionality does work and it isn't too slow.

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.