I want to bind year list in dropdown dynamically.
years should be like 10 years minus from current year and 10 years plus from current year.
e.g, I want years from 2012 to 2032(For now it is done hardcoded, I want to do it dynamic)
I am using vision dropdown.
Can anyone suggest How I can achieve this in ignition?
Thanks.
If you are good with SQL you can look up how to list years like that and bind the data property to a SQL Query Binding or Named Query binding with your SQL.
Alternatively, you can write a script that makes a dataset using system.dataset.toDataSet(), leverage the system.date.* functions to make your list, and bind your data property with an expression binding that calls runScript and calls the function you wrote that returns the dataset of years.
Something like this. Columns may need switched around to work with Dropdown properly.
thisYear = system.date.getYear(system.date.now())
years = [[year] for year in range(thisYear - 10,thisYear + 11) if year != thisYear]
dataSet = system.dataset.toDataSet(['Year'],years)
Ignition can have CTEs in named queries, which you should be using for all Vision UI bindings. But generating via runScript() will be the most performant (no gateway round trip).