Ideally, do nothing.
When I was testing out the orignal script, it did everything okay, until I hit the limit.
I could not deselect them either.
Ideally, do nothing.
When I was testing out the orignal script, it did everything okay, until I hit the limit.
I could not deselect them either.
If you show us what you've got, it may help you get a better answer.
Agree with @lrose, here. Check if it's one to select, then see if you're allowed to. There should be no restriction to unselect it.
Gladly!
def runAction(self, event):
if len(self.view.custom.RouteData) > 4:
return
# Grabs data from the Row that was clicked on.
RouteRow = self.props.data[event.rowIndex]
# Bypasses the extra click to edit a cell.
RouteRow.DESTINATION_SELECTED ^= True
# Depends whether Checkbox is checked or not.
# Will either Append a Row to RouteData or Remove a Row from RouteData.
if not RouteRow.DESTINATION_SELECTED:
self.view.custom.RouteData.append({'DeviceID': RouteRow['DEVICE_ID'],'DeviceName': RouteRow['DEVICE_NAME']})
else:
Index = next(i for i, RouteData in enumerate(self.view.custom.RouteData) if RouteData.DeviceID == RouteRow.DEVICE_ID)
self.view.custom.RouteData.pop(Index)
Perhaps something like this:
def runAction(self, event):
# Grabs data from the Row that was clicked on.
RouteRow = self.props.data[event.rowIndex]
# Bypasses the extra click to edit a cell.
# Check whether it's a cell to unselect
if RouteRow.DESTINATION_SELECTED == True:
RouteRow.DESTINATION_SELECTED == False
# Otherwise check if we can select it
else:
if len(self.view.custom.RouteData) > 4:
return
else:
RouteRow.DESTINATION_SELECTED == True
# Depends whether Checkbox is checked or not.
# Will either Append a Row to RouteData or Remove a Row from RouteData.
if not RouteRow.DESTINATION_SELECTED:
self.view.custom.RouteData.append({'DeviceID': RouteRow['DEVICE_ID'],'DeviceName': RouteRow['DEVICE_NAME']})
else:
Index = next(i for i, RouteData in enumerate(self.view.custom.RouteData) if RouteData.DeviceID == RouteRow.DEVICE_ID)
self.view.custom.RouteData.pop(Index)
@Irose
Oh. That one worked perfectly. I missed that.
Thank you for the help everyone! I really appreciate it.