Welcome! Log In Create A New Profile

Advanced

[WB25] Save and Restore Table Column Order

Posted by Neil Porter 
[WB25] Save and Restore Table Column Order
April 28, 2020 11:25AM
In Webev 24/25 I allow my users to change the size and order of the columns in my table controls using the standard AAF handling.
Is it possible for me to store these changes so that the next time that a user revisits that page, I can restore his/her favourite column layout?

This seems to work automatically in Windev, but not in Webdev

TIA,

Neil.



Edited 1 time(s). Last edit at 04/30/2020 10:26AM by Neil Porter.
Re: Save and Restore Table Column Order
April 28, 2020 01:12PM
Hi, in principle: yes!

There are a few ways, partly depends on the number of table controls within your application contains ..

We decided that you have to have a way to to reset the columns to their original order and width. The code is as follows:

PROCEDURE ResetColumnConfiguration()

TC,TX, TW, TD are int
PopName is string = ControlPopupOwner()
TN is string

TC = TableCount(PopName,toColumn)

FOR TX = 1 TO TC
	TN = TableEnumColumn(PopName,TX)
	TableMoveColumn(PopName,TN,TX)
	IF {PopName+"."+TN,indControl}..InitialVisible = False THEN
		{PopName+"."+TN,indControl}..Visible = False
	ELSE
		{PopName+"."+TN,indControl}..Visible = True
	END	
END

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

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

RETURN

This procedure is added to the system menue of the Table control.

There are some variations possible. This procedure resets all of the columens to their original order, width & visibility. You can make a variant that looks after current olumns made invisible by the user.

Second. You can save all of the columns with their order, width and visibility saved as parameters in the registry.

Third. You could design a .INI file and put all of it there.

Kind regards,
Guenter Predl
office@windev.at
Re: Save and Restore Table Column Order
April 29, 2020 12:34PM
Thank you Guenter,

I should be able to store that layout in my database against each user.

I'm only interested in implementing this solution for 2 or 3 tables.

I'm curious about your call to ControlPopupOwner(). Are you able to add a popup menu to a table control so that a user can right click a table and select an option? I've not been able to find out how to do this in Webdev??

Regards,

Neil.
Re: Save and Restore Table Column Order
April 29, 2020 02:01PM
Hi Neil,

yes, you can add a popup-menue to the "systems"-menue of the table control.

To put the Table's configuration into a database file you could use UserName.WindowName.TableName.ColumnName as a key or put the columns into an array.

Kind regards,
Guenter Predl
office@windev.at
Re: Save and Restore Table Column Order
April 30, 2020 10:06AM
Thank you again Guenter.

I think that maybe the option to add a popup menu to a table is not available in Webdev.

I will experiment with the column layouts over the next few days.

Regards,

Neil.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: