List component filtering and Highlighting

Is this possible with List component?

Ok, I’m sure that’s possible in Ignition, it’s just that I don’t know how to do it… :innocent:

Edit: here is the link where I found this: https://www.logicbig.com/tutorials/java-swing/list-filter-highlighting.html
It pure java and it’s too much for me… :sweat:

Interesting. Not safe to do such things in jython, if you don’t want to end up with un-openable windows. Unfortunately, that example code is not licensed in a way that could be cut and pasted into an Ignition module. /-:

I don’t need the complete filtering and highlighting like in the picture (which would be awesome)…
I have a list component filled with items.
What I need is, when user types in the text box for example letter ‘c’ that the list box highlights the first item which starts with ‘c’. Then user types ‘a’ and the list box highlights the text which starts with ‘ca’, then ‘r’ and list box highlights ‘car’ and so on…

This is very easy to achieve in Angular using filters on client side, not sure if REACT allows this in Ignition 8!

I’ve done this in Ignition with power tables, but it should work with a list component too. The way I did it is by having a text box with Defer Updates and RejectUpdates boxes unchecked. I then place a power table underneath the box running a query like this

Select value From table Where value LIKE CONCAT(:text,'%')

the :text variable is bound to the text entry component. As you type it runs the query to select results that match. You could also concatenate another ‘%’ in front if you want to search for any combination of the input.

I also set the power table to be hidden, it becomes visible when you start typing in the text entry box, then it is hidden again when you click on a value in the power table. the click sets the text entry to the value you click on so you don’t have to finish all the typing to select a value.

hope that helps

The dynamic dropdown cloud template might be an interesting starting point:

Thank you all.


I ended up with this (in project script library) which works with table and list component:

def isci(comp, searchstring):
	search = searchstring.lower()
	data = fpmi.db.toPyDataSet(comp.data)
	nbCol = data.getColumnCount()
	nbRow = data.getRowCount()
	rowToSelect = -1
	count = 0
	sourceStr = []
	for row in data:
		sourceStr = []
		for x in range(nbCol):
			sourceStr.append(str(row[x]).strip())
		sourceStr = u"".join(sourceStr)
		sourceStr = sourceStr.lower()
		if sourceStr.find(search) is not -1:
			rowToSelect = count
			break
		count += 1
	if 'PMIList' in str(type(comp)):
		comp.selectedIndex = rowToSelect
	if 'PMITable' in str(type(comp)):
		comp.selectedRow = rowToSelect
	return rowToSelect

And I’m calling it from textbox property change event:

if event.propertyName == "text": 
	rowToSelect = project.mojeskripte.isci(event.source.parent.getComponent('listDobavitelji'), event.newValue)

5 Likes