Hello,
I’ve created this in Vision before, but cannot figure out how to get Perspective to do the same.
When clicking on a template in a window, a script would create a dataset and pass it as a parameter to another window when opening it. On the opened window a Template Repeater was bound to that dataset to populate the templates within it. Here is the script I used in Vision:
rackName = event.source.RackName
deviceName = event.source.DeviceName
fastNumber = event.source.FastNumber
gigabitNumber = event.source.GigabitNumber
header = [“PortName”,“RackName”,“DeviceName”]
data = []
i = 1
while (i <= fastNumber):
data.append(["Fast "+str(i), rackName, deviceName])
i+=1
i = 1
while ( i <= gigabitNumber):
data.append(["Gigabit "+str(i), rackName, deviceName])
i+=1
portData = system.dataset.toDataSet(header, data)
window = system.nav.openWindow(‘Device’, {‘DeviceName’ : deviceName, ‘RackName’ : rackName, ‘PortData’ : portData})
system.nav.centerWindow(window)
system.nav.closeParentWindow(event)
The above script worked just fine, but we are switching to perspective. I’ve used the Flex Repeater and it seems like it cannot take datasets, but only jsons. I’ve tried to get this to work with json, but I can’t figure out how to pass it to a parameter on a view and get the Flex Repeater to use it. Below is the (not working) script I came up with:
import json
rackName = event.source.RackName
deviceName = event.source.DeviceName
fastNumber = event.source.FastNumber
gigabitNumber = event.source.GigabitNumber
portData = “[”
i = 1
var = {}
while i <= fastNumber:
portName = "Fast " + str(i)
var.update({“RackName”: rackName})
var.update({“DeviceName”: deviceName})
var.update({“PortName”: portName})
portData += json.dumps(var) + “,”
i+=1
i = 1
while i <= gigabitNumber:
portName = "Gigabit " + str(i)
var.update({“RackName”: rackName})
var.update({“DeviceName”: deviceName})
var.update({“PortName”: portName})
portData += json.dumps(var) + “,”
i+=1
portData = s[0:len(portData) - 1]
portData += “]”
system.perspective.closePopup(’’)
system.perspective.openPopup(“DevicePopupID”,“Device”,params = {‘RackName’:rackName,‘DeviceName’: deviceName,‘PortData’: portData})
The Flex Repeater will populate itself if I copy and paste the json string (from the script) into the parameter by hand, but I can’t figure out how to pass the data from this script into the Flex Repeater automatically.
I would appreciate some advice.