Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 4 Jahren, 10 Monaten
Letzter Beitrag:
vor 4 Jahren, 10 Monaten
Beteiligte Autoren:
Jim Carson, Fabrice Harari, Allard, Piet van Zanten, DerekT

WB18: No totals in a TABLE control?

Startbeitrag von Jim Carson am 23.09.2013 22:36

As we all know WB Tables have no natural way to total a column.
I have a button called "Calculate" and after my table is displayed and quantities are added to each line it displays a row "Total" (which is "Cost" * "Qty" on each line).

How is the best way to calculate the sum of the "Total" column for all displayed rows?




Use the same calculation in the 'Row Display' section of the table - it will then calculate as it fills.

I now see this is WB so probably this is not the answer

von DerekT - am 24.09.2013 07:24
Hi Jim,

There are several options in Webdev.
The calculation depends on how you fill the table.
If it's filled by programming there's hardly any overhead, because you can include the calculations in the loop to fill the table.
If it is based on a query you can loop through the query to do the calculations or include the calculations in the query itself. (calculated field)
Then you can loop through the query or the table to do the calculation of the sum.


von Piet van Zanten - am 24.09.2013 15:10
Hi Derek and Piet,

No. The table is already displayed (by query) when the user adds the QTY for each line. Also it's a pain to enter the QTY field in the table..(three mouse clicks to select and be in edit mode)

Since my table has a max of 5 lines in this example, I think that I have to build a group of static and edit controls that receive the info as the table rows are displayed. Then on the browser side do the calculations the Browser "Exit with Modification(on change)" and the "Calculate" button. Once all is set, then I will send the result back to the Server with the "Book" button. I think this will work. Only weird thing is that the table displays the lines in the correct order (sorted by cost descending). But is filled and fills my statics by record 3, 2, 1 then 4? So the static order is different?

[attachment 655 Screenshot1.jpg]

von Jim Carson - am 24.09.2013 17:06
Hi Jim

I'm guessing that you are filling your statics by looping on your query (ie in the QUERY sort order) while in your TABLE you indicated that the sort order is on a specific field (ie not automatic=queery sort order)

Best regards

von Fabrice Harari - am 24.09.2013 18:20

The table is filled by a query. The query is sorted by one item (cost) descending order. The statics are then filled in the row/line display of the table. I would think that the row/line display order would reflect how the table is displayed. However, when I debug, I can see that when the table row/lines are displayed it goes record 3 then record 2, then 1, then 4???? And that's the order that the statics are built.


von Jim Carson - am 24.09.2013 20:13
Let me rephrase

I understand that the table is filled by a query and that the query is sorted. HOWEVER, when you tell the table to use the query (in the table description, you can ALSO choose a sort order at that level. And mly guess is that THIS sort order is not the same as the QUERY sort order

Best regards

von Fabrice Harari - am 24.09.2013 21:12

I donnot know exactly why you would need statics? Calculation on change etc? calculations on client side ?
I would use ajax and do calculations on the server side. ( donnot want the user to be able to see the calculations in javascript clinet side.)

I would use a looper. Since per row you can put all controls in. In the looper i would put and edt-field and two buttons a + button and a Minus button.

Make the button an ajax button

just my opinion.


von Allard - am 26.09.2013 18:30
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.