I'm used to working on the perspective module but on VISION I'm having trouble getting by
In fact, I created a template view with Custom params : city, visibility(False/True), num_turbine, state.
I instantiate this on a main view.
I instantiated 2 templates (turbine 1 and turbine 2), but I added two checkboxes (turbine 1 and turbine 2) on the main view.
What I want is that : when I click on checkox turbine 1, the tempate turbine 2 should be invisible using custum visibility of template
on dataset of image bellow, if I set visibility = False where egine_num = 1, Wind Energie Turbine 1 will because invisible. But I want do it using checkbox.
The idea that I have is to create a loop whent I clique to checkbox 1, I will loop dataset to update value of visibility column of dataset. But I don't know if it is will work.
I don't imagine this will work as expected. If you are using a repeater in dataset mode, the template is going to be displayed if it is included in the dataset. Binding the visibility of the template's internal components to a custom property will only create gaps in the repeater.
What you probably want to develop is a custom method on the repeater that the checkboxes can call on an actionPerformed event to reevaluate the templateParams dataset.
Example: Simple test template with label bound to a number property:
templateParams property with a column that represents the Number parameter:
All checkboxes in a container, and each checkbox has a custom property to signify which template it represents:
Custom Method on Template Repeater to reevaluate the dataset when the checkboxes are clicked:
#def evaluateDataset(self):
# Get the container that contains the checkboxes
checkboxGroup = self.parent.getComponent('Checkbox Group')
# Create headers and data lists for the template parameters dataset
headers = ['Number']
data = []
# Iterate through the checkboxes in the container and check to see if they are selected
for index, component in enumerate(checkboxGroup.getComponents()):
if component.selected:
# If they are selected, add the template number they represent to the template parameters data list
data.append([component.TemplateNumber])
# Convert the data and headers lists into a dataset
dataset = system.dataset.toDataSet(headers, data)
# Sort the dataset, so the templates appear in the appropriate order
# ...and assign the dataset to the repeater's templateParams property
self.templateParams = system.dataset.sort(dataset, 'Number')
Call the custom method using each checkbox's actionPerformed event script:
# Call the custom method that evaluates the template repeater's dataset
event.source.parent.parent.getComponent('Template Repeater').evaluateDataset()
Hang on, radio buttons or checkboxes? These have completely different function. Radio buttons are for selecting a single option. Checkboxes are for toggling multiple options independently of one another
Eg.
Choosing your gender would be a radio button
Choosing your favourite icecreams would be checkboxes to let you select more than one
What's not clear to me is this: Do you want the turbine that is selected by the radio button to be visible and all of the others hidden, or do you want the one that is selected to be hidden, and all of the others visible?
If you're not going to show more than one template at a time, if you won't repeat the template then i would just use the normal template with a binding on the property engine_num to change it based on the selected button
IMO this is not intuitive to the user, but then I also don't know your application so perhaps it makes since in context. Generally, an operator will select what they want to see, not what the don't want to see.
Assuming you have a template parameter for the visibility, bind the visible property of what you "don't" want to show with an expression binding of the inverted template parameter.
!visiblity
Then use a cell update binding on the Template Parameters dataset to bind the radio buttons to the visibility column of the parameters.