Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
4
Erster Beitrag:
vor 2 Jahren, 3 Monaten
Letzter Beitrag:
vor 2 Jahren, 3 Monaten
Beteiligte Autoren:
Mark Crichton, Paulo Oliveira, GuenterP

Change Table Column order programatically

Startbeitrag von Mark Crichton am 01.03.2016 23:14

Hi

I am unable to find a ay top programatically change th border of table columns.

My clients want to be able to have the columns of a table in different order depending on use\user.

eg table has columns = ID, code,Name ,qty, Price, etc
another user wants ID, qty, code,Name , Price, etc
I am required to have some code ( e.g.: attached to a button) that changes the column order and redisplays the table.
It is easy to change column titles etc, but no option for the position.



Dragging columns is becoming frustration for my users.
Some columns contain controls etc so complex to apply all the parts to each column from scratch, but maybe could it be done that way.

Any help appreciated

Mark

Antworten:

Hi Mark,

TableMoveColumn(..) is your friend !

It's mandatory to sum up the anchoring of all of the Table columns to 100%

In order to restore the Table control to its original configuration just use my ResetColumnConfiguration()



TC,TX, TW, TD are int
PopName is string = PopupField()
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




von GuenterP - am 02.03.2016 06:13
Hi Guenter

Thats exactly what I am looking for.
Much appreciated.
Mark

von Mark Crichton - am 02.03.2016 09:46
If you use the AAF feature to export the table content to excel be carefull with the column order.

check the ConfigureAAF function in the help.

von Paulo Oliveira - am 02.03.2016 10:55
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.