Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 8 Jahren, 3 Monaten
Letzter Beitrag:
vor 8 Jahren, 2 Monaten
Beteiligte Autoren:
Ola, Fabrice Harari, Al

Filtering on two files in WD14

Startbeitrag von Ola am 18.04.2010 13:38

Filtering problem

I have a table control with items linked to two files: the files "Child1File" and "Child2File" are in 1:1 relation. Both file buffers must be in memory at the same time.

The table control is a browsing table based on Child1File and it works fine and fast on its own, without filters, and also when called from elsewhere with a simple scooping filter such as:
HFilter(Child1File,Child1Key,MasterFile.MasterKey)

Now I need to filter the table also so that in addition to the master scoop filter there are also additional filters based on one or more items from either child files, like:
Child1File.ItemA > 0 OR Child1File.ItemB

Antworten:

Hello Ola

From what you describe ChildFile2 is actually a child file of ChildFile1 which in turn is a child of the Master file.

This means that any display of files from ChildFile2 is dependant on its parent in ChildFile1 first meeting the masterkey condition before being able to meet any subsequent conditions.

You could try and hfilter ChildFile1 records to match the MasterFile.MasterKey and then loop through that subset, selecting the items in ChildFile1 that match any other conditions for that file and when a ChildFile1 record is confirmed, select records from ChildFile2 that match ChildFile1.masterkey and then apply any additional conditions to those ChildFile2 records.

Something like:

Hfilter(ChildFile1,MasterKey,MasterFile.MasterKey)
HreadFirst(ChildFile1,MasterKey)
While Not Hout()
If ChildFile1 record equals secondary conditions
Hfilter(CHildFile2,MasterKey,ChildFile1.MasterKey)
Hreadfirst(ChildFile2,MasterKey)
While Not Hout(ChildFile2)
If ChildFile2 record equals whatever conditions
TableAdd()
end
Hreadnext(ChildFile2,MasteKey)
end
HDeactivateFilter(ChildFile2)
end
HNext(ChildFile1,Masterkey)
end
HDeactivateFilter(ChildFile1)



Windev is very quick at these operations.

Regards
Al

von Al - am 18.04.2010 14:14
Thanks Al,

I think i got the point: the filter on two files cannot be done with one HFilter command and therefore I cannot use the old "standard" table, which is "a browsing table on file". I have to build a new table for my current need "by programming".

Thanks for the sample.

regards
Ola

von Ola - am 18.04.2010 16:31
Hi Ola...

you can also build a query with the 2 files and conditions on both of them, and build your table on that query...

Best regards


von Fabrice Harari - am 18.04.2010 18:35
Hi Fabrice,

Thanks for the hint. I thought something like that could be possible.

Ola

von Ola - am 19.04.2010 08: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.