Filtering a table with Named Querie with 3 checkboxes in Ignition Perspective

Hello!

I would like to filter a table with 3 checkboxes, depending on wich checkbox I choose the content of the table is filtered.
Each checkbox corresponds to a possible value in one of the table's columns.

Is posible do this with bindings or is better with a script in Phyton.

Cheers

Do you know about the table's built-in column features?
columns.n.filter.enabled : true
There are other options in columns.n.filter as well.

Show your dataset and explain your checkboxes.

I didn´t know about the columns.n.filter.enabled : true

Now I changing it:
image

This is the part of the named query that show column ESTADO in my table

  (CASE 
    WHEN WORKREQUESTSTATE='00' THEN 'Pendiente'
    WHEN WORKREQUESTSTATE IN ('10','20') THEN 'Generada OT'
    WHEN WORKREQUESTSTATE='30' THEN 'Rechazada'
    ELSE 'Estado Desconocido'
  END) AS ESTADO

This are the 3 checkboxes:
image

Checkboxes and table are in the same Column Container

So, you have a table of data where one column is ESTADO (status) and you want the checkboxes to enable display of one or more ESTADO conditions?

Checkbox Result
None Show only Estado Desconocido.
Pendiente : true Include Pendiente.
Generada OT : true Include Generada OT.
Rechazada : true Include Rechasada.

Is this correct?

None option should show all the rows

the rest is ok

Bad idea.

Ok, then the other way around would be fine, the way you tought

Checkbox Result
None Show only Estado Desconocido.
Pendiente : true Include Pendiente.
Generada OT : true Include Generada OT.
Rechazada : true Include Rechasada.

would need to have all checkboxes selected from begining

We will return all the records to a custom property. Then we will use a script to display only the records of interest. This means that we only query the database once.

  1. On the table, create a custom property, custom.data.
  2. Put your query binding on that.
  3. On the table data property configure like this:
The script transform.
def transform(self, value, quality, timestamp):
	output = []
	for row in value['data']:
		if value['chkPend']:
			if row['ESTADO'] == 'Pendiente':
				output.append(row)
				continue
		if value['chkGene']:
			if row['ESTADO'] == 'Generada OT':
				output.append(row)
				continue			
		if value['chkRech']:
			if row['ESTADO'] == 'Rechasada':
				output.append(row)
				continue			
		if row['ESTADO'] == 'Estado Desconocido':
			output.append(row)
			
	return output
3 Likes

Following your instructions but seem something not working right:

Maybe is not clear where the error is, cheers.

Edit your Prueba-13 named query and remove the filter parameter. You want it to return all the records. The script will do the filtering.

Wait: is that a different radio group or the filter radio group?
In your screenshot you have cut off the preview. What is the result of the query?

1 Like

Sorry, I forgot to tell you to set the query Return Format to JSON (which is what the script is expecting).

1 Like

This part of the custom.data is working fine now

the part of the expression on the table.data seem to have an error

maybe this helps:

See post #12.

Wow, working great!, thanks Transistor.


image

Now I will try to start with all checkboxes selected and add the radio button filter we did yesterday.

Cheers.

Ok, just added the radio button filter as you teach me yesterday in the custom.data binding and both are working fine together.

Thanks

2 Likes

Good work.

Suggestion: I think your full-cell color is too much and black on red is never good. Here's a trick:
Modify the style and set the left border to 20 px and add some color there instead. You get a nice indicator with an easy-to-read text beside it. There is no need to "scream" color! Be cool, man! Be cool!

Subtle color indicator

You need to do this for each different style that you use.

2 Likes

Thanks for the advice! just implemented it.
image

1 Like