How to make a Table forget its column configuration?

Startbeitrag von Jimbo am 04.05.2009 14:50

HI,

I do want my users to enjoy the memorizing of the column configuration of a Table control. But users should be able to reset the column configuration every now and then to the original configuration. How to do that??

Kind regards,
Guenter

Solution: TableMoveColumn(..)

Antworten:

Hello Guenter,

The stored tableconfiguration is written in the registry (unless you changed it with InitParameter to another place). So you can delete the specific entries there.

I don't use the automatic saving of the configurations but let my users save the settings or remove the settings by rightclicking the table. I write the settings in an INI-file and remove them on demand.

HTH.

von Louis Verbraak - am 04.05.2009 15:10

Hi Louis, deleting the registry-entries is a good & fast one! Using TableMoveColumn(..) works but is 18 lines of code I wanted to avoid. The INI-File sounds fine but is too much hassle for me with several hundred Tables in a project.

Thank you for the insight!
Guenter

von Jimbo - am 04.05.2009 15:36
Hello Guenter

I allow my users to clear the registry settings in a couple of ways.
The simplest, with no coding is to right click on the application window and use the option in the standard AAF popup menu that is the default in all windows.

The other method is to pass the formname to a process that can clear the registry.
You can't do this in the actual window because the last thing a window does as it shuts down is to refresh the registry. You have to clear the registry in the code that called the window

IF GProjRegistryKey "" THEN
//GProjRegistryKey holds the name of the window to delete in the registry
LWindowRegKey is string = ""
LWindowRegKey = ProjectInfo(piRegistry)+"\"+GProjRegistryKey
RegistryDeleteKey(LWindowRegKey)
GProjRegistryKey = ""
END


Regards
Al



von Al - am 05.05.2009 11:44

Re: How to make a Table forget its column configuration? SOLUTION

Quote
Jimbo
HI,

I do want my users to enjoy the memorizing of the column configuration of a Table control. But users should be able to reset the column configuration every now and then to the original configuration. How to do that??

Kind regards,
Guenter


Hi all,

the universal solution to reset the original column configuration with all of the colums visible for all tables of a WinDev application is as follows:

1 - Make a new Popup menu, presumably named Popup1

2 - Edit the caption to 'Reset column configuration'

3 - add an appropriate menu icon

4 - add the code as shown below


TC,TX are int
TN is string

TC = TableCount(Table,toColumn)

FOR TX = 1 TO TC
TN = TableEnumColumn(Table,TX)
TableMoveColumn(Table,TN,TX)
{"Table."+TN}..Visible = True
END



5 - Add the Popup1 menu to the system menu of the Table
5a - in WD14 description of Table control Tab GUI .. combo Popup Menu .. check System Menu and check Add Popup Menu and select Popup1
5b - in WD12 add to the initialization code of the Table the code line
MySelf..PopupMenu = "+Popup1"

That's it. Any Table of the application will be able to use this code. However, you'd have to add this popup menu to each window of the application with a Table control on it and you'd have to make another Popup menu for each Table control on the same window..

Kind regards,
Guenter



von Jimbo - am 14.08.2009 18:15

Re: How to make a Table forget its column configuration? ENHANCED SOLUTION

Hi, using this procedure in the real world has revealed that there was necessity for some improvements.

1 - the routine makes all columns visible and doesn't select the initially visible ones only.

2 - the routine doesn't resize the columns on order to show the table as it had been designed originally.



TC,TX, TW, TD are int
TN is string

TC = TableCount(Table,toColumn)

FOR TX = 1 TO TC
TN = TableEnumColumn(Table,TX)
TableMoveColumn(Table,TN,TX)
IF {"Table."+TN}..InitialVisible = True THEN
{"Table."+TN}..Visible = True
{"Table."+TN}..Width = {"Table."+TN}..InitialWidth
TW += {"Table."+TN}..Width
END
END

TD = Table..Width - TW - 18 // 18 ~= Width of vertical scrollbar of Table
FOR TX = 1 TO TC
TN = TableEnumColumn(Table,TX)
IF {"Table."+TN}..InitialVisible = True THEN
{"Table."+TN}..Width += TD * {"Table."+TN}..AnchorRateWidth / 1000
END
END


Note 1: I wasn't able to find the width of the vertical scrollbar of the table programmatically. Vertical scrollbars of my tables ('110 System') are 18 pixels in width ..

Note 2: to make the second part of the procedure work, take care that the AnchorRateWidth of the visible colums add up to 100%

Kind regards,
Guenter

Quote
Jimbo
Quote
Jimbo
HI,

I do want my users to enjoy the memorizing of the column configuration of a Table control. But users should be able to reset the column configuration every now and then to the original configuration. How to do that??

Kind regards,
Guenter


Hi all,

the universal solution to reset the original column configuration with all of the colums visible for all tables of a WinDev application is as follows:

1 - Make a new Popup menu, presumably named Popup1

2 - Edit the caption to 'Reset column configuration'

3 - add an appropriate menu icon

4 - add the code as shown below


TC,TX are int
TN is string

TC = TableCount(Table,toColumn)

FOR TX = 1 TO TC
TN = TableEnumColumn(Table,TX)
TableMoveColumn(Table,TN,TX)
{"Table."+TN}..Visible = True
END



5 - Add the Popup1 menu to the system menu of the Table
5a - in WD14 description of Table control Tab GUI .. combo Popup Menu .. check System Menu and check Add Popup Menu and select Popup1
5b - in WD12 add to the initialization code of the Table the code line
MySelf..PopupMenu = "+Popup1"

That's it. Any Table of the application will be able to use this code. However, you'd have to add this popup menu to each window of the application with a Table control on it and you'd have to make another Popup menu for each Table control on the same window..

Kind regards,
Guenter





Edited 2 times. Last edit at 08/15/09 08:57AM by Jimbo.


von Jimbo - am 23.08.2009 20:54
Quote
Louis Verbraak
Hello Guenter,

The stored tableconfiguration is written in the registry (unless you changed it with InitParameter to another place). So you can delete the specific entries there.

I don't use the automatic saving of the configurations but let my users save the settings or remove the settings by rightclicking the table. I write the settings in an INI-file and remove them on demand.

HTH.

Kind regards,

Louis.


Hi Louis, after trying both, I decided to go the copy & paste path. It doesn't introduce any additional parts into the window and I can tweak the code for each table individually. In future, I'll try the use of PopupField() in order to become independant of the table name.

Kind regards,
Guenter


von Jimbo - am 24.08.2009 05:54
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.