cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass a Value selected from an Application to a Chart in a Composite?

JYOUSAF
Participant
0 Kudos

Does anyone know how to pass a value selection from an application to a composite. My main application has a listbox. Application also has a composite that houses a chart. When the user makes selection(s) in the listbox, it is supposed to filter the chart in the composite. Is there a way to pass the value(s) selected from the listbox in the application and pass them to the chart in the composite to filter chart data?

I stored the value selected from the listbox in a global variable but hasn't been able to find a way to pass it to the chart in composite. Currently looking into datasource alias property within composite but not sure if it can achieve the above requirement?

Accepted Solutions (0)

Answers (3)

Answers (3)

MartinKolb
Advisor
Advisor

Using a DataSource in both the application and a composite usually works this way: You define a data-source in the main application and pass it to the composite. Then you can manipulate it from the main application’s code (e.g. setFilter), and the components in the composite get updated if they are bound to this data-source.

This data source sharing works via the following steps:

1) In the composite, define an Interface Property of type “DataSourceAlias”

2) In the composite, you can then assign this DataSourceAlias to a component of the composite, e.g. a Chart.

3) In the application you can assign your application’s DataSource to the the DataSourceAlias of the composite.

From that point on, all modifocations in the DataSource of the application will also be reflected in the DataSource of the Composite.

Best,

Martin

JYOUSAF
Participant
0 Kudos

Martin,

Thanks for explaining how a data source in composite can be controlled from the host application using datasource alias property.

However, I am unable to replicate the same for a listbox that is populated via java script getMemberList method.

So I have a listbox (LB_Main_App) in the main application. Listbox is populated via getmemberlist java script method as below:

LB_Main_App.setItems(DS_1.getMemberList("_WIvwdfdfffffW9OaTTA", MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT,550));

The same listbox is also in the composite (LB_Cmp). I need to populate LB_Cmp with the same dimension as LB_Main_App.

Here are the steps I took within composite:

  • 1.Created an Interface Property of type ‘Datasource Alias’ (DS_cmp)
  • 2.Within the main app, under composite’s data binding properties, assigned DS_cmp to DS_1.
  • 3.Within the composite, selected the listbox (LB_Cmp), under LB_Cmp properties, binded Data Source DS_Cmp as its data source. Now when I attempt to select a dimension under ‘Dimension’ property, I get an error (in Error Log) that says “Unhandled even loop exception’.
  • 4.I, then, assigned DS_Cmp to another data source in main app, and when I try to bind DS_Cmp to the LB_Cmp, I get the same error as above.
  • Not sure what causes this error? Am I doing it right? Is there a workaround to achieve the above requirement? Would love to gain some insights here.
  • Thanks.
MartinKolb
Advisor
Advisor

The "Unhandled even loop exception" is most likely a bug in Lumira Designer and I encourage you to open a bug ticket.

The reason why such an error arises, is that at design-time, the component does not yet know which data-source will be assigned at runtime. Therefore, it is not possible to pick a dimension at runtime.

As a workaround you can fill the listbox with a line of scripting in the component. Each component has an event “On Initialization”. In this event, you can simply add a similar call, which you already used to fill the listbox of the application:

LB_Cmp.setItems(DS_cmp.getMemberList("_WIvwdfdfffffW9OaTTA", MemberPresentation.INTERNAL_KEY, MemberDisplay.TEXT,550));

Best regards

Martin

jbreznar
Participant
0 Kudos

Thank you, this helped me a lot!

former_member189544
Contributor

Hi!

You could create an interface function (setter) in the composite, that can be triggered from the main application in script. Here you can pass in the value from your combobox and apply the according filter to your chart in the composite.

Regards,

Harald

JYOUSAF
Participant
0 Kudos

I do have a function in composite that gets triggered from the main application. However, I'm unable to expose any property of composite to the main application. Interface function of the composite is the only thing that gets exposed to the main application. Below is the setup at a high level:

Main Application:

ListBox (On Select): GV_LB =listBox.getSelectedValue(); //storing selected value in a global variable.

Launch_Composite_Button (On Select): This script from main application calls an interface function (fnc_cmp) of composite.

Composite:

fnc_cmp: here I am unable to access GV_LB from within the composite.

I tried creating a datasource alias property within composite but unable to bind it with original data source from main application.

MartinKolb
Advisor
Advisor

Hi,

interface functions can have parameters. The easiest way would be to pass the value of GV_LB as parameter to fnc_cmp.

Best,

Martin

JYOUSAF
Participant

Was able to pass the values from the host application to the composite via parameters. Thanks for the suggestion.

MartinKolb
Advisor
Advisor
0 Kudos

In addition to the setter function mentioned by Harald, you would typically expose the data-source of the chart in the composite as a “Interface Property” of the composite.

The data-source would then be owned by the application (and not the composite). In the application you can then make calls like “setFilter” to the data-source. The Chart inside the composite, which is bound to that data-source, will then automatically reflect that changed filter.

Maybe that helps.

Best,

Martin

JYOUSAF
Participant
0 Kudos

Can you please explain how do I expose chart data source from composite as an interface property? Tried with datasource alias property but no luck.

Appreciate the help on this matter!