Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 11 Monaten, 3 Wochen
Letzter Beitrag:
vor 11 Monaten, 3 Wochen
Beteiligte Autoren:
Scott Daughtry, GuenterP

Preserving sort order when returning from Form to Table window

Startbeitrag von Scott Daughtry am 28.11.2016 15:11

WD21 apps: from a Table window I double left click a table entry to display it's associated FORM window; when I exit the FORM window the table's sort order undoes itself. How can I capture the table's sort order before the FORM window opens and then restore it when the focus returns to the TABLE window (and is there a tweak I can make elsewhere in the RAD template) to stop this unwanted behavior?

Simple test to confirm this problem: on a TABLE, manually sort the table by clicking column headers on two different columns (e.g. first click the STATE column and then the CITY column) - open the FORM window, close it and see what happens to the table's sort - it has changed on you :(

Antworten:

Hi Scott, as an example, if you have a table with customer names and the customer number as a unique identifier then we return from the Form to the Table with the customer numer and TableSelectPlus(..) the Table to that customer number.

If Form and Table are on different windows, you can call the Form with a customer-ID as a parameter for modification and no customer-ID / customer-ID = 0 for adding a new customer. The Form itself returns a customer-ID when closed which is the customer ID to select in the calling Table. When having mixed uses of Tables and Forms, means that those windows are either not called or a returned customer-ID is not expected then just use a global variable for that purpose.

von GuenterP - am 29.11.2016 08:47
Hi Guenter - thank you, as always, for great advice.

I think I understand what you are describing and will give it a try tonight when I sit down at the keyboard. I remember having this same problem when I was using WD19... I've always used the default PCSoft RAD pattern to generate the generic application and was surprised that the table's sort status wasn't preserved by default when a form window is called - and when the form window is closed and you return focus back to the Table window the sort order status wasn't restored..

:)

von Scott Daughtry - am 29.11.2016 16:41
Hi Guenter,

I got it to work! I changed the RAD-generated code within the MODIFY button on the Table Window to the following code:

IF TableSelect(TABLE_VidTrak)=-1 THEN RETURN

// Grab the unique identifier so we can reposition the table bar when the Form window is closed
gnUniqueID = VidTrak.VidTrakID

// Open the Form window to edit the record
Open(WIN_Form_VidTrak)

// Refresh the table so the edited record is displayed within the table
TableDisplay(TABLE_VidTrak)

// Repositions the bar of the table on the computer that was viewed - modified
// Seek out the saved identifier number in the table
NSubscript = TableSeek(COL_VidTrakID,gnUniqueID)

// Reposition the highlight bar on the saved identifier numbr
TableSelectPlus(TABLE_VidTrak,NSubscript)


The sort orders on the calling Table aren't disturbed when the Form window is closed and the highlight bar is repositioned on the edited record.

Thank you VERY much for your invaluable assistance!

von Scott Daughtry - am 30.11.2016 04:03
Hi Scott, you're welcome!

von GuenterP - am 30.11.2016 07:26
I spoke prematurely; the previous code didn't preserve the AAF sort order. After many failed attempts I did get this code to work every single time - even when I sorted on multiple columns via AAF:

*-- start
// Grab the unique identifier so we can reposition the table bar when the Form window is closed
gnUniqueID = VidTrak.VidTrakID

// Open the Form window to edit the record currently selected in the table
Open(WIN_Form_VidTrak)

// The form window is now closed and data likely modified
// Repositions the bar of the table on the computer that was viewed - modified
// Seek out the saved identifier number in the table
NSubscript = TableSeek(COL_VidTrakID,gnUniqueID)

// Reposition the highlight bar on the saved identifier numbr
TableSelectPlus(TABLE_VidTrak,NSubscript)

// Refresh the TABLE with the modified information without disturbing AAF sorting
SetFocus(COL_Moviename) // without resetting the focus to the first column of the column the form window will
// keep reopening endlessly
SendKey("{ENTER}") // refreshes the table to display the modified data
SendKey("{ECHAP}") // without sending an ESC key into the buffer the form window will keep reopening
// endlessly if the MODIFY button was clicked; this wasn't required if the table
// was left clicked with the mouse however
*----

This code was added to the MODIFY button located on the WIN_TABLE window.

von Scott Daughtry - am 02.12.2016 04:44
Hi Scott, my code looks a bit different

// ---- in " FOCUS gain of Table_ARTIKEL "
// Refresh table data?
IF FOCUS = False THEN // FOCUS is a boolean variable to prevent from running this routine
// Iconize(""); Maximize("") // 0 THEN // NEW_ART_NUM is the global variable
MyPosition = TableSeek(Table.ART_NUM,NEW_ART_NUM,True)
TableSelectPlus(Table,MyPosition)
NEW_ART_NUM = 0
END
END
Refresh()

von GuenterP - am 02.12.2016 07:38
Interesting.. when I added refresh() into the code I get an error - the online help on the WD web site showed a REFRESH procedure but no REFRESH() function :(

von Scott Daughtry - am 02.12.2016 23:32
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.