Diese Seite mit anderen teilen ...

Informationen zum Thema:
Forum:
WinDev Forum
Beiträge im Thema:
5
Erster Beitrag:
vor 8 Jahren, 1 Monat
Letzter Beitrag:
vor 8 Jahren, 1 Monat
Beteiligte Autoren:
Alan, DW, Piet van Zanten, Milton

Filter a table

Startbeitrag von Alan am 06.08.2009 18:38

Hi guys,

Can anyone tell me where I'm going wrong with this please? I've got a table control showing the contents of a table which has records called 'jobs' inside with a click button above it. A 'job' has two statuses, either 0 or 1. I just want to be able to show ALL jobs OR just the ones where the status is not 1 (Completed). The code I have will hide the Completed ones, but when I press it again does not show ALL the jobs again.

MySelf..Caption=(MySelf..Pushed?"Show Completed Jobs" ELSE "Don't Show Completed Jobs")
IF MySelf..Pushed =True THEN
showcomps=True
HDeactivateFilter(JobSchedules)
HFilter(JobSchedules,COMPLETED,0)
ELSE
showcomps=False
HDeactivateFilter(JobSchedules)
HFilter(JobSchedules,COMPLETED,"COMPLETED >=0" )
END
TableDisplay(TABLE_JobSchedules)
TableSelectPlus(TABLE_JobSchedules, 1)


Many thanks for any help !
Regards
Alan

Antworten:

Hi Alan,

MySelf..Caption=(MySelf..Pushed?"Show Completed Jobs" ELSE "Don't Show Completed Jobs")
IF MySelf..Pushed =True THEN
showcomps=True
HDeactivateFilter(JobSchedules)
HFilter(JobSchedules,COMPLETED,0)
ELSE
showcomps=False
HDeactivateFilter(JobSchedules)
// remove this line, hdeactivatefilter will show ALL records HFilter(JobSchedules,COMPLETED,"COMPLETED >=0" )
END
TableDisplay(TABLE_JobSchedules
,taInit // taInit will refresh the table content
TableSelectPlus(TABLE_JobSchedules, 1)

Regards,
Piet

von Piet van Zanten - am 06.08.2009 20:07
Hi Alan,

I have a similar issue which I resolved this way -

I have a radio button at the top of a table for the user to select one of 3 states



The radio button has the following code -

IF Radio1= 1 THEN
HFilter(HELPDESK,TotalActive,1,1)
END

IF Radio1=2 THEN
HFilter(HELPDESK,TotalCompleted,1,1)
END

IF Radio1=3 THEN
HFilter(HELPDESK,TotalActive,0,1)
END

In this case I have constructed a composite filter key of TOTALACTIVE.

However, I would have been better to not use filtering at all and to simply construct 3 queries to support each of the statuses I wanted to display since this would make my application much faster as I only need to load the records needed for dispaly rather than loading the whole table and then filtering the records. In fact, I will change this now that I have re-looked at it.

In any case, you may wish to consider using queries instead of filters yourself.

HTH

Milton

von Milton - am 06.08.2009 20:09
Hello Alan,

I agree with Milton on queries instead of filters that is the power of Windev more then one way to do things.

I do something similar on a lot of my tables but use a combo box with 3 choices:
Active, Inactive, All

//This is a Query with a parameter set on the active status if you want all records skip the parameter and execute the query.

SWITCH COMBO_ActiveStatus
..CASE 1 //Active
.....QRY_Warehouse_Table.Param_Status = 1
..CASE 2 //Inactive
.....QRY_Warehouse_Table.Param_Status = 0
..CASE 3 //All
.....//Do nothing
END

Or if you want to use the filter like Milton.
Switch Radio1
.. Case 1 //Active
..... HFilter(HELPDESK,TotalActive,1,1)
.. Case 2 //Inactive
..... HFilter(HELPDESK,TotalCompleted,1,1)
.. Case 3 //All
..... HFilter(HELPDESK,TotalActive,0,1)
END

Also there is a 3 state checkbox from time to time I use for this purpose.

Just my 2 cents

Dennis W

von DW - am 07.08.2009 13:39
Ok, thanks for both suggestions, I'll give them a go !

von Alan - am 07.08.2009 17:15
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.