WINDEV, WEBDEV et WINDEV Mobile
|Using a Form as a Popup Window|
|Débuté par Antonio Díaz, 31 déc. 2020 02:11 - 6 réponses|
Posté le 31 décembre 2020 - 02:11
Since I am only starting to use Webdev (or any PC Soft solutrion for that matter), what would seem easy becomes hard. In this case I am using a Looper control to display the contents of a Data File and want to update a certain row in another window. Since I am trying to use one single window for my app, I am using the Planes and the Popup windows.
What I want to achieve is for the Form (to update a record) to be part of a popup window. So far I haven't been successful because the popup window always display the first record of the Looper. I remember when using a different window, I would send the unique identifier as a parameter to the form window to make sure it would locate the right record. However, as far as I know the popup window is part of the same (calling) window, so how can I go about this?
Thank you in advance for your help!
Emphasys Software, S.C.
Posté le 31 décembre 2020 - 11:38
Use the ATT_ property in the looper rather than the file variable itself. If you look in the description of the Looper, at the top of the general tab, the are a list of attributes linked to the controls. Use them as the identifier the retrieve the record using that.
Hope this helps
Posté le 31 décembre 2020 - 18:45
Thanks Simon.... it didn't work.... the popup page always retrieves the same (first) record... Still trying to find the problem...
Posté le 02 janvier 2021 - 14:54
I feel for you and this is where Windev, WEB, and mobile suffers from strength, this is just my opinion.
I dont know what type of mechanism you are using to call your Popup form, however I will try the following:
Lets look at some scenarios here
Your looper is linked to the database itself (Not to a query)
Lets say your table is Customers
So, you are viewing Record Number 20 in your looper as for this example Customer Number "6556446"
I will construct a Query, either by code or physically in your project name "Qry_Get_Customer" with a parameter named pCustomer_Number (The "p" is so that you identify your Parameter when typing your code)
attach the Lopper or the Table of the PopUp to this query then
Create a Button to call the Popup and on the Click (Ajax) Event ON YOUR FORM Not on the Popup.
Qry_Get_Customer.pCustomer_Number = Your_Table_Name.Col_Customer_Number) or Your_Looper_Name.ATT_Customer_Number) This will pass the record selected number into the pCustomer_Number Parameter
TableDisplay(Your Table Name Here) or
LooperDisplay(Your Looper Name Here)
Now you open your Popup, and that record should be displayed there.
Now, scenario 2 is attaching the same table FILE (CUSTOMERS) NO QUERY to both, the form and the popup to both the form and the popup.
You do a
HReadSeekFirst(CUSTOMERS, CUSTOMER_ID, YOUR TABLE NAME.COL_CUSTOMER_ID)
Then here you do a TableSelectPlus Function like this
TableSelectPlus(YOUR POPUP TABLE NAME HERE, TableSelect(YOUR FORM TABLE OR LOOPER NAME HERE NAME HERE)
And Open your Popup.
I hope this helps
Posté le 04 janvier 2021 - 11:45
What Carlos has said should work. If you still have a problem, then check that the control that is linked to reference to the file in the looper is an edit control set to Numeric and not a static control. I had a similar problem yesterday. I was using a static control and it was returning "5" not 5. So whichever looper I clicked on, it always selected the first to display. Changed it to an edit control and it worked perfectly.
Hope this helps
Posté le 08 janvier 2021 - 20:21
I've read your post several times, first of all, I really appreciate it. Second, I've been using Webdev for a few weeks now and still consider myself a beginner so I would like to ask you what do you mean by Form and Popup. The way I see it, the Form is the Popup window that will be displayed for the user to edit the values of the record but when you write:
<<Create a Button to call the Popup and on the Click (Ajax) Event ON YOUR FORM Not on the Popup. >>
I get confused.
Third, I think I might be misunderstanding but, am I supposed to use the looper to display only one record? (the one I want to edit) and then call the popup?.... I believe I am still not sure if you meant that, sorry for my inexperience.
Emphasys Software, S.C.
Posté le 12 janvier 2021 - 05:53
Hi Antonio sorry for responding so late.
It should be Page instead of Form.
and for the next question, is No, you can use the looper to see all the records but you need to use
TableSelectPlus(Your Popup Table Name here, TableSelect(MyTable_fromThe_Page_Name_Here)
Let me explain the TableSelectPlus what it is like a find command.
In order for the TableSelectPlus to work needs to have a value for example 20.
Where you get this value and assign it to the TableSelectPlus? from your Page Table.
When you click with your mouse on a record in your Page's Table, automatically that has an invisible Record number, which PCSoft calls it subscript (Which I Hate with Passion). This invisible number we can get it by
saying TableSelect(YourTable Name) for example TableSelect(Table_Customers)
So if you click on the 3rd row of records in your Table_Customers
and put this code on a button Ajax-enabled,
info(TableSelect(Table_Customers)) //You are going to get a message with the Number 3 on it
See? Now when you open your popup you say
TableSelectPlus(Your Popup Looper name here, TableSelect(page_customer.Table_Customers))
The cursor should land on the 3rd row of the Looper, then you do a file to page then you edit or whatever.
I miss my Delphi programming. Delphi was and still is the king in this matter, but not as good as Webdev doing Web
Let me know if you got it working.