Select multiple checkboxes in a table - Perspective

Hi guys,

I need to select multiple rows in a table and send the values to a label in another view.
I tried to use the checkbox column to select them, but I can only check one at a time. The selection mode is set to multiple interval.
What am I missing?


image

Thanks!

Did anyone get this to work?

How are you setting the check box (for the single row)?
With the mode multiple interval you can select multiple rows using ctrl + click or shift + click (for a range)

We will use the system on phones and tablets as well. The shift + click or ctrl + click works fine on computers, but not on these touch devices.
I wondering to just touch the checkboxes to make multiple selections like ctrl + click.

add an onRowClick() event on the table:

something like if you use json format: (if column name is checkbox)
self.props.data[event.row].checkbox = not event.value.checkbox

then you can send all the data where checkbox==true

1 Like

i did scripting on onRowClick() event on the table
the table data needs to update to the database when the checkbox is selected.

Below is the checkbox column prop…I have created a view for checkbox coz by selecting render as boolean and boolean prop as checkbox, it should be clicked twice to select the checkbox

below is my code for checkbox column… i tried passing vcheckbox==“true” also but getting error for both

       vcheckbox=self.props.data[event.rowIndex].isselected
	system.perspective.print(vcheckbox)
	
	if vcheckbox==1:
		system.perspective.print("checkbox:true")
	else:
		system.perspective.print("checkbox:false")

error is:

caused by org.python.core.PyException
Traceback (most recent call last):
  File "<function:runAction>", line 31, in runAction
TypeError: 'com.inductiveautomation.ignition.gateway.datasource.BasicStreamingDataset' object is unsubscriptable


plz help me

seems your data is in dataset form not json, to get the value from a dataset you need to do
vcheckbox=self.props.data.getValueAt(event.rowIndex, "isselected") or something
https://docs.inductiveautomation.com/display/DOC81/Datasets

Thanks for your reply

if render selected as view then checkbox reflecting and if auto then blank

if checkbox selected then its value should be passed as 1 or true but I am getting output in console as blank

I need the selected property of checkbox which we can see in normal view but in table’s column checkbox I am not getting that property so how can it be handled?

vcheckbox=self.props.data.getValueAt(event.rowIndex, "isselected")
	system.perspective.print(vcheckbox)

o/p got blank after selecting/deselecting checkbox

Yes…

Seems you arent really understanding what is supposed to be happening here.

First of all how are you getting the data? How did you add in the column for isselected?

Are you passing the values down to the view? or is it just a checkbox? Because why arent you just using the boolean render.
Also you gotta set the value on row click, that was the whole point of not needing two clicks.

vcheckbox=self.props.data.getValueAt(event.rowIndex, "isselected")
self.props.data = system.dataset.setValue(self.props.data, event.rowIndex, "isselected", not checkbox)

you should do this and use boolean render

@victordcq ic query binding done to display the data in table and isselected is the column with null value getting from the table and I should pass 1 in isselected column and that entire row’s data to the table only if checkbox is selected else nothing/null/0…

basically I need to pass the row’s data only based on checkbox selection

should I do it on editcell commit ?but how can get the value of checkbox as true/1 or false/0

I want this property in table column of checkbox from where I can achieve it…

plz help me

You could send a message when you press the check box but its really just gonna be easier to use the boolean render xd

no editcell required, we are handling the “edit” on row select because it requires one click less (for booleans)

this works for me for a simple dataset with boolean render. Ofc you gotte be sure the dataset isselected is set to boolean. and that the query isnt refreshing else it will overwrite the edits in the data prop

onrowclick event:

self.props.data = system.dataset.setValue(self.props.data, event.rowIndex, "isselected", not self.props.data.getValueAt(event.rowIndex, "isselected"))

Isselected column value got changed by clicking row but it needs to be changed only when I tick the checkbox …if I untick that checkbox again then null/0

How can I send a message when checkbox ticked :upside_down_face:

Plz look at this below img: here under data prop they have boolean value for inactive and other 2 cols…the same way I want it for checkbox column …is it possible?

ahhh you can use onselectionchanged then. there you get
event.selectedRow and event.selectedColumn

you can then do an if on the event.selectedColumn to see if its a boolean column
and use the script but use event.selectedColumn instead of “isselected”
and selectedRow sintead of rowindex

heh for some reason this keeps getting triggered for me tho :confused:

checkbox on table column is not possible in perspective?

seems like you will have to use the edit mode afterall
enable edit and use oneditcommit
it requires an extra click tho

I tried on oneditcellcommt as well but the difficulty is If i deselect the checkbox then also it is passing the value 1 in isselected column :upside_down_face: coz it is taking as edit committed…what can be done to fix it ?
is there any way to get only boolean value in isselected column like the below image where in data props they added isactive as boolean value

show me your code

Hi,
It did work for me.
I have a binding for this table and I’m creating a fake column called Checkbox in the query:

Then, I created an event onEditCellCommit with the script:
if self.props.selection.data[0].Checkbox == True:
self.props.data[self.props.selection.selectedRow].Checkbox = True

Finally, I set my button to get all the data from my table where the value on Checkbox column is True.

2 Likes

@augusto.junior @victordcq Thanks for your reply
I scripted on oneditcellcommit and it has printed the value as true/false in console when I select/deselect this was achieved by printing event.value and in scripting need to use 1/0 instead of true/false and from that value, I have given condition to pass the table row’s checkbox ticked data to database

checkbox=event.value
	system.perspective.print(checkbox)
if checkbox==1:
	system.perspective.print("true conditn")
else:
       pass
1 Like