Question about multiple select row from a db table

Hello,

I've been in this world for 4 months, so sorry if my question is a bit basic.

I'll try to describe it as briefly as I can: I'm working on some filters for a Window in Vision. All my data comes from a DB. One of these filters is a filter by items (it needs to be multi-selectable by operators, not single-target). Right now we have 7/8 items, but I don't know if that number could grow in the future. Anyway, I'm handling the other filters using Vision Client Tags.

My question is: what's a good method for multi-selecting items (touch-friendly) that I can then read from my query once the selection is made? I searched the forum and saw that the "List" component seems perfect for this kind of thing, but the issue I think I'd run into is that multi-row selection only works on PC (via Ctrl + mouse click), and wouldn't be possible in situations where operators only have touch screen access.

I'd prefer a component-based/binding solution over custom scripting, if possible.

I hope I explained myself clearly.

Thank you

Luca

Have you seen this:

https://forum.inductiveautomation.com/t/how-to-do-multiple-selection-from-a-vision-list-component/82348/4?u=zxcslo

Or this:

https://forum.inductiveautomation.com/t/multiselect-dropdown-in-vision/58749/7?u=zxcslo

Search is very powerfull thing...:innocent:

I've never tried it on a touchscreen, but I imagine a larger font size could make the rows big enough:
Ignition Exchange: MultiSelect Dropdown for Vision

It's been a long time since I made that, but I'm pretty sure it uses a JTable under the hood. If there's enough room in your UI, a standard table or power table with the Selection Mode set to multiple interval would be a good choice for this sort of thing.

4 months is too young to work with computers

This will have the same problem as the list - without ctrl/shift held down, Swing's default behavior is to move the selection, not add to it.

It's technically possible to work around this with the standard list, but distinctly annoying, and probably not worth doing given the OP's other constraints.

Clanker Crimes
if event.propertyName == 'componentRunning':
	from javax.swing import DefaultListSelectionModel, ListSelectionModel

	class TouchToggleSelectionModel(ListSelectionModel):
		def __init__(self, oldModel=None):
			self.delegate = DefaultListSelectionModel()
			self.gestureStarted = False

			if oldModel is not None:
				self.delegate.setSelectionMode(oldModel.getSelectionMode())
				minIndex = oldModel.getMinSelectionIndex()
				maxIndex = oldModel.getMaxSelectionIndex()
				if minIndex >= 0 and maxIndex >= minIndex:
					for index in range(minIndex, maxIndex + 1):
						if oldModel.isSelectedIndex(index):
							self.delegate.addSelectionInterval(index, index)

		def addListSelectionListener(self, listener):
			self.delegate.addListSelectionListener(listener)

		def addSelectionInterval(self, index0, index1):
			self.delegate.addSelectionInterval(index0, index1)

		def clearSelection(self):
			self.delegate.clearSelection()

		def getAnchorSelectionIndex(self):
			return self.delegate.getAnchorSelectionIndex()

		def getLeadSelectionIndex(self):
			return self.delegate.getLeadSelectionIndex()

		def getMaxSelectionIndex(self):
			return self.delegate.getMaxSelectionIndex()

		def getMinSelectionIndex(self):
			return self.delegate.getMinSelectionIndex()

		def getSelectionMode(self):
			return self.delegate.getSelectionMode()

		def getValueIsAdjusting(self):
			return self.delegate.getValueIsAdjusting()

		def insertIndexInterval(self, index, length, before):
			self.delegate.insertIndexInterval(index, length, before)

		def isSelectedIndex(self, index):
			return self.delegate.isSelectedIndex(index)

		def isSelectionEmpty(self):
			return self.delegate.isSelectionEmpty()

		def removeIndexInterval(self, index0, index1):
			self.delegate.removeIndexInterval(index0, index1)

		def removeListSelectionListener(self, listener):
			self.delegate.removeListSelectionListener(listener)

		def removeSelectionInterval(self, index0, index1):
			self.delegate.removeSelectionInterval(index0, index1)

		def setAnchorSelectionIndex(self, index):
			self.delegate.setAnchorSelectionIndex(index)

		def setLeadSelectionIndex(self, index):
			self.delegate.setLeadSelectionIndex(index)

		def setSelectionInterval(self, index0, index1):
			if not self.gestureStarted:
				if self.delegate.isSelectedIndex(index0):
					self.delegate.removeSelectionInterval(index0, index1)
				else:
					self.delegate.addSelectionInterval(index0, index1)
				self.gestureStarted = True

		def setSelectionMode(self, selectionMode):
			self.delegate.setSelectionMode(selectionMode)

		def setValueIsAdjusting(self, isAdjusting):
			if not isAdjusting:
				self.gestureStarted = False
			self.delegate.setValueIsAdjusting(isAdjusting)

	jList = event.source.viewport.view

	oldModel = jList.getSelectionModel()
	newModel = TouchToggleSelectionModel(oldModel)
	newModel.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION)

	jList.setSelectionModel(newModel)

If it’s less than a dozen or so items I would consider a pop-up window with some simple labels and check boxes.

If it grows much larger than that I would use a table tied to a dataset tag with a selectable Boolean column to utilize available table filtering techniques.

:grimacing: I see the problem

It's trivial to add an editable boolean column to a table, so that would be a viable solution even if there are many rows.

You could modify the query to include an arbitrary boolean column, or you could put the raw data from the query on a custom property, and add the column and data to the table on a property change event. The user could then select the rows using the checkboxes without having to do anything funky.

Psssst! Try my Integration Toolkit's selectStar() function in the table data binding. Something like:

selectStar({path.to.raw.dataset}, asMap('toggleName', 'b'), false)

That will deliver the toggles pre-set to off when the raw data changes.