PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 22 → WD21 - TableDisplay question
WD21 - TableDisplay question
Débuté par Arie, 07 mai 2018 16:41 - 5 réponses
Posté le 07 mai 2018 - 16:41
I can't seem to get this to work.
I have a tabelcontrol showing data from an array of structures.
On doubleclick an edit window popsup where the user can modify the current record.
When this window is closed I want to redisplay the table so is reflects the changes.
My code is reading the new values from the db an updates the array of structures accordingly. No problem.
Then I want the table control to rediplay one single row of data.

I tried all options, taCurrentSelection taCurrentReccord and so on, but with no luck.
Every time the whole table is redisplayed and the "sort" (done by the user by clicking on or more columntitles) is gone.

Is this not possible is this table mode?
Posté le 07 mai 2018 - 17:39
Hi Arie,

WX can't do what you want to do out of the box as it's data binding is not as advanced as many other grids these days...

But (as mostly) there is a workaround. If you're using WD only you can:
- Throw the complete structure (it would be the same when using objects/classes) from the grid/array you have highlighted to the detail window (Something like StructureReturned is StructDef = Open(DtlWin,StructureArray[ i ]))
- Next you work on that object/structure and return the object/structure itself again to the browse window with the grid in case of an OK/Save in the detail window
- Next you update it in the array used by the grid: StructureArray[ i ]=StructureReturned
- Next you redisplay only that row

It'll provide you also less db traffic as well if you do it that way...

My 2 cents,

Peter Holemans
Posté le 07 mai 2018 - 19:09
Thanks Peter, still around I see :-)

I already do all the steps, that means 1-3 more or less.
When coming back form the edit-window I update only the required record in the array of structure. All the rest remains as-is.

My problem is the last step: how to redisplay a particular (or the selected) row.
The taCurrentSelection option still redisplays more than I want, causing the table to scroll in some way. Also the users sort is lost.

I'm now building a small procedure do it al my self. Using indirection I think I will get the job done with only a tablename and a rownumber. All the rest can be done using BrowsedFile on the tablecontrol and FileLink on each column. Hopefully,
Posté le 09 mai 2018 - 13:41
Hi Arie,

you could use
i is int = index of the modified arrayentry
x is int = tableselect(TABLE_xy)
TABLE_xy.COL_Changedvalue1[x] = array.value1
TABLE_xy.COL_Changedvalue2[x] = array.value2
and so on
Posté le 09 mai 2018 - 14:39
Did that already :)

// // refresh a row of a table, bound to an array of structures // PROCEDURE TableDisplayRow(LOCAL sTable is string, LOCAL nTableRow is int, LOCAL nArrayRow) sSource is string = {sTable,indControl}..BrowsedFile sItem is string IF {sTable,indControl}..Occurrence < nTableRow THEN RETURN END FOR i = 1 TO {sTable}..NumberColumn WHEN EXCEPTION IN sItem = {sTable+"."+TableEnumColumn({sTable},i)}..FileLink sItem = ExtractString(sItem,2,".") // i.e.: convert :garrAdresses.Street to :garrAdresses[nRow].Street //Trace({sTable + "[" + nRow + "]" + "." + TableEnumColumn({sTable},i)} ,{sSource+"["+nRow+"]"+"."+sItem,indVariable}) {sTable + "[" + nTableRow + "]" + "." + TableEnumColumn({sTable},i)} = {sSource+"["+nArrayRow+"]"+"."+sItem,indVariable} DO //Error(ExceptionInfo()) END END
Posté le 10 mai 2018 - 09:03
Hi arie,

If the arry is updated already you can do a tablemodifyline(0 on the table. It modifies the line.
Then when you click in the table the value of the arry gets past and since that is already good it will work

regards
Allard