Guys, has anyone seen a template which would save and restore column widths of browses or lists in a window? So that a user can set a preferred widths and things stay that way?
Thanks
Bostjan
Guys, has anyone seen a template which would save and restore column widths of browses or lists in a window? So that a user can set a preferred widths and things stay that way?
Thanks
Bostjan
There is one included, Global Properties / Actions ⌠/ App Settings / Enable List Format Manager
I had a function that did that at my last gig.
Canât post the code, but it was not complicated. Basically looped through the PROPList:Widths and concatenated the values using @N05. And read the data back using deformat.
Probably 8-10 lines of code total.
Rather than save just the widths, I save the whole format string and then restore it.
One thing to watch out for, whatever method you use.
If you add or change columns, then you should reset the saved info.
If you are saving/restoring the whole format, like I do, then restoring an format for an older version of the list control is pretty bad.
If you are just saving the widths, like @jslarve suggests, it wonât be as bad restoring a saved format to a new version of the list control. But the widths will go to the wrong columns.
I save the original development time format. Then when the procedure opens, I compare the saved original dev format with the current dev format. If it has changed, I do not restore the userâs saved format.
My template is originally based on the one available from the ABC Free template/classes. The SaveControlFormats template.
https://www.authord.com/products/Clarion/
Groups are often left as Resizable so should also do List [Groups] with the same code loop saving PROPLIST:Group + PROPList:Widths
in a separate line of lengths.
As Rick suggested a way to spot changes is to also save the âOriginal Widthsâ from the LIST. Then before setting them check that the current âOriginal Widthsâ from the LIST match the ones you saved.
This is some code to give you an idea how to grab widths
ListWidthsConcatN05 PROCEDURE(LONG ListFEQ, BOOL bGroupFlag=False),STRING
Widths ANY
ColNo LONG,AUTO
Prop_Width LONG,AUTO
CODE
Prop_Width=PROPLIST:Width + CHOOSE(~bGroupFlag,0,PROPLIST:Group)
LOOP ColNo=1 TO ListFEQ{PROPLIST:Exists,0}
Widths=Widths & FORMAT(ListFEQ{Prop_Width,ColNo},@n05)
END
RETURN Widths
ListWidths_Col_Original = ListWidthsConcatN05(?List1)
ListWidths_Grp_Original = ListWidthsConcatN05(?List1,True)
Before setting List to saved widths be sure saved "Originals" match ListWidths_Col_Original and ListWidths_Grp_Original
Hi @Bostjan_Laba , have you tried with putini.
Something like this:
On CloseWindow embed
putini(âTab_Artâ,âSELECTEDTABâ,?CurrentTab{prop:selected},âapp.iniâ) or
PUTINI(âTab_ARTâ,âARTIKLIâ,?Browse:1{PROP:FORMAT},âGRIDS.INIâ)
And then try to read the .ini file with getini on OpenWindow procedure. This way every user can set the width of columns as they prefer.
I never liked the idea of saving PROP:Format. It is too easy for someone (user or developer) to mess it up. Also, it can provide a way for bored people to look at queue fields that you donât want them looking at.
This width info can be saved with the window resize data. With a âreset windowâ menu choice that kills that ini section.
I can see 2 other problems with saving the entire FORMAT:
If saved to an INI file that file format has a 1024 byte limit per line which the Format() length can exceed 1024. You could truncate the Format and not know it. I think 50 columns should be no problem so not a common issue. The code should protect against this checking for 1024.
If your logic to reset relies on spotting the Original LIST Format() changed then you would reset the saved column widths on Any Format Change no matter how minor. So if you just changed the Heading, Tool Tip, Resized Columns, etc⌠the user would lose his saved widths. I make a lot of cosmetic LIST changes ⌠using my tool to get columns sized just right âŚ
Edit 4/7/23
C. The Format() can contain line breaks as binary 13,10 (e.g. in a Heading ~ Line1 <13,10> Line2 ~
). If saving the entire Format() to an INI itâs important to use QUOTE() to convert that to text <13,10>
because the 13,10 mid-line will mess up an INI and the read GETINI will not work. Use UNQUOTE() on the GETINI.
Iâll take a moment to plug my List Format Parser that allows looking at the FORMAT columns easily by splitting them into rows. Handy for source compare. You can Preview any Format pasted from Code. It will generate a Format() from a Queue, and more:
There is also the template RunScreen from Capesoft. I use since years without problems.
https://www.capesoft.com/accessories/Runscreensp.htm
Thank you for all the ideas, very helpful. I might go with RunScreen but I must be sure it will work with my resizing template which also influences lists. If not, Iâll go with width saving.