Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
12
Erster Beitrag:
vor 5 Jahren
Letzter Beitrag:
vor 4 Jahren, 5 Monaten
Beteiligte Autoren:
Clarion Ghost, GuenterP, Chris du Toit, Geoff B

How do I change the target action of a button at run time

Startbeitrag von Clarion Ghost am 30.09.2012 17:12

A Button is preset to display a pdf in a New Browser. = New browser (_blank):

I need to have the option of destination. How do I program the button to change destination and display in the Current Frame (_self) at runtime?

(See http://doc.pcsoft.fr/en-US/?1010044)

Many Thanks

Antworten:

I have a button on each row of a table (Looper)
The button is set to display a pdf in a new browser when clicked.
However if there is no pdf stored the current page is duplicated in a new browser.
Changing the Button Target on the fly would resolve the issue.

ChangeTarget(CurrentBrowser) is available in Browser code. Could I use this to achieve the result I require?

File is string = ""
HReadSeek(Transaction,TransactionID,LOOP_QRY_Transactions.ATT_STC_TransactionID)
IF Transaction.pdffile = "" THEN
How do I Change the Target to the Current Page at this point
ELSE
HExtractMemo(Transaction,pdffile,"File")
FileDisplay("File" , "application/pdf")
END

von Clarion Ghost - am 01.10.2012 06:16
Hi CG, why not make this button simply invisible in those rows where you knowthat there's no PDF document available? Guenter

von GuenterP - am 01.10.2012 06:54
Hi GuenterP

That is a good idea. I had thought about 'grayed' but I couldn't work out how to do it in the data line? (Doing something in the Button Click Code affected all the buttons?)

How would I code a data line to affect just the button on that specific line?

Many Thanks

von Clarion Ghost - am 01.10.2012 07:08
Hi, it's done in the 'Row Display' process of the Table / Looper.

IF NOT .....condition.for.pdf.available... THEN
Looper123.button123..visible = False
END

You need not define the row because the display process selects the row for you.

Regards,
Guenter

von GuenterP - am 01.10.2012 07:22
Hi GuenterP

IF NOT LOOP_QRY_Transactions.ATT_pdfFile = "" THEN
LOOP_QRY_Transactions.BTN_Document..Visible = True // Show Button
END

When I run this code in Row Display all the buttons display. If I change Visible = false, then all the buttons are hidden.

I have tried several variations. Have I made a mistake with the code?

Many Thanks

von Clarion Ghost - am 01.10.2012 13:47
Quote
Clarion Ghost
Hi GuenterP

IF NOT LOOP_QRY_Transactions.ATT_pdfFile = "" THEN
LOOP_QRY_Transactions.BTN_Document..Visible = True // Show Button
END

When I run this code in Row Display all the buttons display. If I change Visible = false, then all the buttons are hidden.

I have tried several variations. Have I made a mistake with the code?

Many Thanks


Yes, put the NOT away and define = False

von GuenterP - am 01.10.2012 15:05
Ian - I think I had a similar problem with hyperlinks...they all show or all dissapear.

You need to use the attribute functionality to indirectly show or hide the button. So add an attribute to the looper, tie it to a button control with the visible property. Then, in your row display, toggle the value of the attribute.

von Chris du Toit - am 01.10.2012 15:12
Hi Guenter

IF LOOP_QRY_Transactions.ATT_pdfFile = "" THEN
LOOP_QRY_Transactions.BTN_Document..Visible = False // Hide Button
END

This either shows all or none? How does WebDev distinguish between an empty item an a full item at Row Display?

Chris - Sorry I don't understand what you mean by 'attribute functionality'; and how is it added to the looper?

von Clarion Ghost - am 01.10.2012 15:39
If you double-click your looper in the description you will see the attributes of your looper (eg. ATT_column1, ATT_column2).

An attribute is tied to a control, and a control property.

Always manipulate the attributes of the looper, not the control itself.

Most times, the attribute is tied to the control content. In your case, you want to add a new attribute to your looper, tie it to a button control, and then tie it to the "visible" property. It's all done on that one window in your looper description.

Then in your row display, you just toggle the value of the attribute to true or false and the button will show or dissapear for that row only. I'm not in front of a Wx install right now so I can't take a screen shot, but check out the help on Loopers. Attributes within loopers is key to manipulating loopers properly. The best way to see it working is to tie a looper to a DB file or query and see how Wd sets that up itself.

von Chris du Toit - am 01.10.2012 15:44
Thank you Guys,

After creating the attribute ATT_BTN_Document..Value and setting it to False, the code that seems to work in Row Display is:

IF LOOP_QRY_Transactions.ATT_pdfFile = "" THEN
LOOP_QRY_Transactions.ATT_BTN_Document..Value = False // Hide Button
END

Brilliant

I have just had a quick look through the Looper Help. Is it possible to gray the button rather than hide it?

Many Thanks

von Clarion Ghost - am 01.10.2012 16:37
Halleluiah!

Thanks for this post, I was going nuts trying to hide a button in a looper, until I found this!

IF ATT_CfmHoursID..Value = 0 THEN
ATT_ChangeButtonVisible = True
ELSE
ATT_ChangeButtonVisible = False
END

von Geoff B - am 15.05.2013 08: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.