Dropdown Filters for Historical Chart

Hello. I have created a historical chart on my project. This chart will be used by leaders to see where an operator badges in. This chart has dropdowns tied to it that filter through Line, Workcenter, Name, Start Date and EndDate. They are all separate dropdowns and all have different scripts. They are live dropdown filters, so when you choose a selection the table changes immediately through several if statements.

For example:

#Line is not empty, Area/Name/StartDate/EndDate is empty, do this:
if (Line != "") and (Area == "" and Name == "" and StartDate == "" and EndDate == ""):
    system.db.runNamedQuery("Historical/Line/1", {"Line" :Line})
	returnedData = system.db.runNamedQuery("Historical/Line/1", {"Line" :Line})
	self.parent.parent.getChild("Table").props.data = returnedData

The above named query “Historical/Line/1” filters so that every item in the database with a matching line will display in the table and so on for every combination available for each and every dropdown filter. My problem is that the dropdown filter does not filter until I hit the clear button I have to clear the filters. If I try to filter before hitting the clear button, the table simply says “Empty Data Source”. I’m not sure what is causing this problem. My clear buttons’ code is as follows:

self.getSibling("LineDropdown").props.value = ""
self.getSibling("WorkCenterDropdown").props.value = ""
self.getSibling("StartDateDropdown").props.value = ""
self.getSibling("EndDateDropdown").props.value = ""
self.getSibling("NameDropdown").props.value = ""
	
system.db.runNamedQuery("ClearFilter", {"Line" :Line, "Area" :Area, "Name" :Name, "StartDate" :StartDate, "EndDate" :EndDate})
returnedData = system.db.runNamedQuery("ClearFilter", {"Line" :Line, "Area" :Area, "Name" :Name, "StartDate" :StartDate, "EndDate" :EndDate})
self.parent.parent.getChild("Table").props.data = returnedData

The “ClearFilter” named query only returns * from the database that the table is binded to. Any tips or knowledge is appreciated. Thanks in advance.

I don’t know if this helps but you might consider using None rather than "". The Python None would get converted to a props.value : null.

1 Like

Because there are a lot of moving parts here, I would say this may be a good question for support. Having access to your system to troubleshoot live should help to isolate the issue.

1 Like

Thanks for the reply. I’m new around these forums, how exactly do I contact support?

Start here:

https://support.inductiveautomation.com/

1 Like

I am now realizing that what is causing the filters to not work is the DateTime Inputs I have. I have one for Start Date and one for End Date (to locate the time people badged in). The filters will not work because the value for those is automatically set to null. If there is a way to set this to empty, the filters will work.

As transistor said, change everything that’s empty to null, and check for None in your scripts. Or check for truth, both null and empty will be considered false in python.

1 Like