Hi, I have 4 Instance of chart in View Canvas
But i open a popup in 2nd chart of instance. I want to get the View Canvas number dynamically and pass it to the popup
suppose if i delete the 2nd chart i want to know which instance i am deleting for that purpose also
Instance number i am talking about
How to achieve this?
There are multiple ways to achieve this, depending on how you're opening the Popup and/or deleting instances.
Opening a Popup which receives the instance index:
A. Opening the Popup from within the View that contains the chart.
This View will automatically receive a param with a key of index
from the Flex Repeater. You should manually place this index
param at the View level and default it to something which would NOT make sense given the context; I recommend a value of -1
so that when you reference the value in any scripting you can identify the default value. Now when the View opens a Popup it can pass along the index of this instance of the View.
B. Opening the Popup from the Flex Repeater:
The Flex Repeater does have an onInstanceClick
Event, but this event is probably not the best route as you'd be forced to open your Popup via a left-click Event. Maybe this isn't so bad, because I don't see any UI in the chart View being instanced to open a Popup... I recommend placing some UI in the chart View to do so.
Deleting a chart instance:
This is both simple AND complicated, because you need to determine if you're just removing an instance from your list or if you're modifying some query in order to return a different set of instances.
Wherever you want to delete an instance from the list, use system.perspective.sendMessage("DELETE_FR_INST", params={"index": <instance_index_here>}, scope="page")
. Then configure a Message Handler listener on the Flex Repeater and allow the Flex Repeater to manage the removal logic.
Simple route:
Inside the listener, do something like this:
# deletes a specified index from the instances array/list
del self.instances[payload["index"]
More complicated route:
Depending on your avenue for populating the instances list, you'll want to run the query or script again, using the listener script to specify which index to omit.
1 Like
I am using view canvas component inside flex container.
You have given example for flex repeater
Is it applicable for view canvas component?
Delete instance i have understood
But I didn’t understand example how to get the instance.
I have 2 popup one is outside of the view canvas and another popup will come along within the charts
If possible can you give me clear example
My mistake, but the principle remains the same, and the View Canvas shoudl also be providing an index
as a param for each instance.
For me to provide more guidance, you need to clearly define what each Popup needs in order to function and how each Popup is being opened. Do both need the instance index? If one is opened outside the View Canvas, I don't know how you'd pass an index as the View Canvas wasn't interacted with.
I have question if there any way to add index number to each chart custom property?
if possible it will easy for me to pass index number to chart popup using that custom property of chart
note: each chart will have a button that will open the popup
popup purpose to configure tag to the chart and also edit the configuration
i have found it how to pass instance from view canvas to chart
each instance have view params.