Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
8
Erster Beitrag:
vor 11 Monaten
Letzter Beitrag:
vor 10 Monaten, 4 Wochen
Beteiligte Autoren:
Scott Daughtry, GuenterP, Allard, Fabrice Harari, Tor-Bjarne

Lookup table usage on data entry forms

Startbeitrag von Scott Daughtry am 27.12.2016 19:54

Happy holidays all,

How are you providing end-users the ability to add/edit/delete database records stored in a lookup table from your Form windows? I currently don't see a way to do this... and am chasing my tail .

I use a combobox control on my Form window to access the lookup table data because
a) Incremental search helps speed up data entry
b) Can display a drop list of lookup table values to enforce data integrity

.. but the combobox doesn't let you add/edit/delete the lookup table data.

For you Clarion converts, what I am seeking is what the old Prodomus PDLOOKUP template does for the Windev world...

Thoughts?

Antworten:

Hi Scott,

our standard-solution is to add a button next to the combo with [ + ] on it which simply opens the standard-window to input the new record. Since all of our standard-windows are MDI, this one is an MDI-Child as well. Now, data of the new record are entered and the windows is closed. Now, the calling window gains focus. The trick is to refresh all refreshable controls on that window - but not on each and every "Focus gain" event, that event is activated more often than really necessary. However, for refreshing a Combobox you have to
- find out and memorize the currently selected item
- re-load (= initialize) the combo with data. Now, the new record will be there!
- re-point the combo to the initially memorized item
looks like

// File FAKTPER, unique key is FP_NUM, so the name of the Combobox control is the same
REFRESH_FP_NUM = Tab1.FP_NUM // FP_NUM is the combobox control that sits on a Tab control named Tab1, REFRESH_FP_NUM is 2-byte int and remembers the original element's position in the combo

ListDisplay(Tab1.FP_NUM,taInit) // this is the actual refresh of the combo on Tab1

REFRESH_POSITION = ListSeek(Tab1.FP_NUM, REFRESH_FP_NUM, True) // REFRESH-PSOITION is a 4-byte int and contains the result of the ListSeek operation which finds the position of the original element in the combo's content. ListSeek(..) will return the combobox's element number (a positive result) if the element could be found, a negative (-1) if the element couldn't be located

// now we can re-position the combo on its original element
IF REFRESH_POSITION > 0 THEN
ListSelectPlus(Tab1.FP_NUM, REFRESH_POSITION)
ELSE
ListSelectPlus(Tab1.FP_NUM,1) // No find. So, we position it on our custom line (#1) which says: Please, select an element for ...
END

Of course, there will be a long list of elements to be refreshed in the "Focus gain" event, but it's simply routine to add them after doing it for several windows ..

Initializing the variable
FOCUS is boolean = True

=== Focus gain ===
IF FOCUS = False THEN
Maximize("") // we maximize our MDIs always, so they fill the frame of the MDI-parent
FOCUS = True

... all of the refreshes come in here

END

=== Focus loss of form ... ===
FOCUS = false

von GuenterP - am 28.12.2016 08:23
Hi Scott,

depending on the need, I use two methods:
- the one described by Guenter, but with a twist: instead of a + button, it's a MANAGE button (generally a gear icon) where the user open a window to add/edit/delete (if allowed) from the lookup table.
- instead of using a combo, I use a non edit field (or an edit/search) field and a popup window/popup cell that comes on when entering/clicking the field. This method allows for a more advanced search function but is a little more disruptive in term of entry flow.

Best regards

von Fabrice Harari - am 28.12.2016 09:38
Good morning Fabrice and Guenter,

As always, thank you for your invaluable assistance! I will give your method a try

Happy Holidays,
Scott

von Scott Daughtry - am 28.12.2016 14:26
Hi,

When it comes to combo I would add and an " [[ New ]] " entry at the top or bottom of the combo and if you are using GLINK (should be turned on default if you ask me, but needs to be turned on in properties of combo), position inside the combo is quite easy.

The function/Features requires only 2 small blocks of code:


//Initcode of Combo

s is string = " [[ None ]]"+gLink(-1)+CR

ListDeleteAll(COMBO_Status)
IF HExecuteQuery(QRY_Get_StatusTX,hDefault) = True THEN
FOR EACH QRY_Get_StatusTX
s = s + QRY_Get_StatusTX.Status_TX + gLink(QRY_Get_StatusTX.PRIMARYKEY) + CR
END
END

s = s + "[[ New ]]" + gLink(-2) +CR
ListAdd(COMBO_Status,s)

//In Selecting a Row of combo

nRec is int

SWITCH COMBO_Status
CASE -1
Bilag.StatusID_txt = ""
CASE -2
nRec = OpenPopup(win_makeStat_TX,"") //Win_MakeStat Will return new recordID

IF = nRec 0 THEN
ExecuteProcess(TAB_Custino.COMBO_Status,trtInit)
Combo_Status = nRec //Reposition combo on new combo-record
//Set StatusID field with the recordID of Get_StatusTX`s primary record
Bilag.StatusID = Combo_Status

END

OTHER CASE
Bilag.StatusID = Combo_Status
END


And to retrieve/point to correct Combo_line when retrieving master record I only have to do:


Combo_Status = Bilag.StatusID

// OR the combo_status could be linked to Bilag.statusID then
// WinDev could do a lot more automatically




Cheers
Tor-Bjarne

von Tor-Bjarne - am 28.12.2016 19:05
Is it possible within the Entry Field's combobox to trap the ALT-DownArrow keypress to then call the lookup table's Window procedure so the enduser can add/edit/delete lookup table database content - and then detect when that popup window has closed to then automatically refresh the combobox to make the lookup table's altered contents appear within the combobox?

von Scott Daughtry - am 29.12.2016 15:34
Hi Scott, I wouldn't recommend to do so because you'd have to treat the called window differently from a standard input window. Remember: our way to do it uses the standard input form. Which doesn't prevent the user from changing several combos on the same window and return to the original window after closing all of the other windows. It may even require to open any number of sub-windows to fill in the form for the combobox-file successfully. All using the standard windows which are already there. Any deviation from that principle will sooner or later require to duplicate windows. If your application has 300 windows (a small one) then add another 300 ...

von GuenterP - am 30.12.2016 08:37
Hi,

I donnot see that problem. It is quite doable with one window.

I use a button for that ( activate the procedure that calls the popupwindow ) but there is no reason why you couldnot use a key press in the combo it self. I would not do it but it can be done for sure.

You have to pass parameters to the popup window and when the adding deleting stuff is done do pass paramters back and do a listdisplay() based on that.

But that's just one possible solution. It all depends on how you do your programming. Do you data bind or not are you using mdi kind of windows. , etc etc can have an impact on how to do stuff

But in general this is quite doable.

Regards
Allard

von Allard - am 30.12.2016 10:03
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.