Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
10
Erster Beitrag:
vor 4 Jahren, 9 Monaten
Letzter Beitrag:
vor 4 Jahren, 9 Monaten
Beteiligte Autoren:
Raymond Thomas, Al, Geoff B, Markus K.

Fill Table Programatically

Startbeitrag von Raymond Thomas am 17.04.2013 11:18

I want to fill a Table programically with different queries depending on the user selection from a Treeview.

Some queries have parameters and others don't. Each time the user selects a different option from the Treeview the table must be cleared and then filled with the associated query.

What is the best way to accomplish this?

Antworten:

Hi,

execute the query and then use tableaddline:

HexceuteQuery(QRY_SELECT_XY, hquerydefault, param1...)
for each QRY_SELECT_XY
tableaddline(Table_X, QRY_SELECT_XY.value1, QRY_SELECT_XY.value2....)
next

greetings

von Markus K. - am 17.04.2013 11:53
Hello Raymond

In the "Content" section of the table, set the fill to File/Query then run the query with its new parameters and display the table.


On each change of parameters
HFreeQuery(MyQuery)
Switch MyTreeviewOption
Case 1
MyQuery.pParam1 = WhatEver
MyQuery.pParam2 = WhichEver
Case 2
MyQuery.pParam1 = WhatEver
End
TableDisplay(MyTable,taReExecuteQuery)




Following on from Markus suggestion there is also a FileToMemoryTable() function that can work if your table column structure exactly matches the query field structure

Regards
Al

von Al - am 17.04.2013 11:55
Thanks for the replies. I used Al's solution since it was easier to fill the table.

von Raymond Thomas - am 17.04.2013 13:04
After I filled the table I ran into a problem using the TableEnableFilter command. Previously I used the following command to change the filter on the table:

TableEnableFilter(MyTable.StartMonth, filterEqual,"October")

StartMonth is a field name in the query and is also displayed as the column name in the table header. Now I get an error that StartMonth is unknown. How do I reference the table column now that it is filled from a query?

von Raymond Thomas - am 18.04.2013 10:05
Hello Raymond

I have never used the TableEnableFilter() function but your syntax appears to be correct. From reading the help, I don't believe the query is the issue. While the help indicates that the correct syntax is tablename.column name, this is done to uniquely identify the column because you can have tables with duplicate column names on the same window. In the early days of Windev you only needed the column name and so most of the table commands will work with just the column name as a string so you could try TableEnableFilter("StartMonth",filterequal,"October)

I have always maintained that I get as much ( and sometimes more) out of answering forum questions as the person who posed the original question and this is a classic case. I had no idea there was a command to enable/disable a table filter in this manner and answering this question has solved a problem that came up for me yesterday, so thanks for raising it. :cheers:

So to all the lurkers, please join in the discussions, you will find it is mutally beneficial.

Regards
Al

von Al - am 18.04.2013 13:48
Thanks Al,

I tried your suggestion and it did not work at first but I did eventually get it working. :cheers:

Although the column name was StartMonth in the table and the query it came up with an error of "unknown control" even with the quotes. I then tried "_COL9" which I read somewhere in the help that it is the format of the default column names and it worked perfectly - 9 being the column number.

Thanks again for your help.:xcool:

von Raymond Thomas - am 18.04.2013 14:35
@Al, yes I have a similar question at the moment with WebDev17, so I'll join in as well!

I have a looper on a page that is filled from a VIEW I created in the mysql database. I want to apply a filter to the view used for the looper, but can't see where to do that?

(As a Clarion user I am used to having a place where a filter can be specified for the table data)

Do I have to specify a Query in order to apply a filter to the view/table used for my looper, or is there a similar property that can be specified to filter file/view data in a looper?

von Geoff B - am 19.04.2013 13:02
Hello Geoff

I use views quite a lot but have never tried to apply a hilter to them. I normally "filter" the data using the conditions that I set in the view creation. In a lot of cases I have to step through the view records in read loop because I need to gather additional table in my table fills so I can always screen out other records with additional code before filling the table

I looked into using HFilter() on a view and it works ok, you can use it in exactly the same way as you would for the file the view is based on. You can use the filter creation wizard to build the filter using the actual file and then change it to the view filename after the wizard completes. I can't see it working on a merged or joined view however.

I don't use Webdev or loopers so I can't say how it will work in that environment.

Regards
Al

von Al - am 20.04.2013 08:57
Thanks Al,

I've still got a lot to learn! I want to conditionally apply the filter at runtime, so adding the filter to the view won't do it.

I'll have a look at hFilter, and experiment a bit more - I'm sure it will be easy, I just thought it would be a bit more obvious! :)

von Geoff B - am 20.04.2013 10:04
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.