I wish to populate a Carousel with DataSet data. My thinking is that this would be similar to populating a FlexRepeater.
-Is there a Python command to create a new View under view.Carousel.props.views?
-Is there a Python command to create a new Value under view.Carousel.props.views[#].viewParams?
The idea is to have a Carousel of variable length.
You’d want to build a dataset where each item in the dataset is a an object which has a viewPath key and an internal list named viewParams where each entry is a tuple of viewParam key:value pairs.
pseudo-code:
view_list = []
# for each entry in your list
for i in range(len(view_dataset)):
# make a new viewPath key:value entry
view_list[i]['viewPath'] = view_dataset[i]['view_path']
# if we also have viewParams for the entry
if view_dataset[i]['view_params'] is not None:
# make a new dictionary with a key of 'viewParams' to hold the keys and values
view_list[i]['viewParams'] = () # dictionary, not list
# for every param we specify
for j in range(len(view_dataset[i]['view_params'])):
# set our viewParam dictionary to have a key which is our first value in the tuple, and a value which is our second tuple value
view_list[i]['viewParams'][view_dataset[i]['view_params'][j][0]] = view_dataset[i]['view_params'][j][1]
# set our props.views value to be our new list
self.props.views = view_list
There’s got to be a less-verbose-but-more-visually-complicated way to manage that, but there you go.
hard-coding a dataset worked for me:
first_view_dict = dict()
first_view_dict['viewPath'] = 'Templates/PopupViews/Displays/Icon/ComponentSettings'
second_view_dict = dict()
second_view_dict['viewPath'] = 'Experimentation/ReplThree'
second_view_dict['viewParams'] = dict()
second_view_dict['viewParams']['End Time'] = 'Supplied'
third_view_dict = dict()
third_view_dict['viewPath'] = 'Templates/PopupViews/Inputs/Dropdown/ComponentSettings'
view_dataset = dict()
view_dataset['views'] = []
view_dataset['views'].append(first_view_dict)
view_dataset['views'].append(second_view_dict)
view_dataset['views'].append(third_view_dict)
self.getSibling('Carousel').props.views = view_dataset['views']
1 Like