cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger Datasources based on Selector(Combox )

former_member195446
Participant
0 Kudos

Hi,

I have requirement need to Trigger Datasources based on Selector(Combox having:13 days,YTD,13 Weeks).

I have created 3 Data Sources which is for 13 days,YTD,13 Weeks

I need to trigger 13 days when I select 13 days from combobox,similarly if I select 13 weeks need to trigger 13 Weeks Datasource,etc..

Please help me.

Thanks,

Prasad

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Prasad,

Assuming that your data sources are labelled "DS_13DAYS","DS_YTD" and "DS_13WEEKS", you will have to incorporate the following code into the "onSelect" event of your dropdown menu:


var Selected_Option = DROPDOWN_1.getSelectedValue();

if(Selected_Option == "13 Days")

{

  DS_13DAYS.loadDataSource();

}

else if(Selected_Option == "YTD")

{

  DS_YTD.loadDataSource();

}

else

{

  DS_13WEEKS.loadDataSource();

}

Also, ensure that the "load in script" property for these data sources are set to "true" during design time. You could also use a global variable as a flag to check if a data source has already been loaded, as a further enhancement to this code.

I hope this helps.

Thanks and Regards,

Eshwar Prasanna

former_member195446
Participant
0 Kudos

Hi Eshawar

yea that's correct and i similarly want to bind the all datasources into one chart only.

means if I select 13 days then 13 days data will bind to that chart and similarly if its 13 weeks and bind to same chart.

please help me in this.

Thanks,

Prasad


Former Member
0 Kudos

Hi Prasad,

To achieve this functionality, you will only have to use only 1 data source and change the queries that you have bound the data source to dynamically at run time (Data source bound to a chart cannot be changed at run time). Here's a sample, to be implemented in the "onSelect()" event of your dropdown - assuming that data source "DW_SWITCH" is bound to your chart:


var Selected_Option = DROPDOWN_1.getSelectedValue();

if(Selected_Option == "13 Days")

{

  DS_SWITCH.assignDataSource("cuid:ARZelWdoCTlDkY.nFZRRlM4", DataSourceType.QUERY, "ZDS_EXERCISE_01");

}

else if(Selected_Option == "YTD")

{

  DS_SWITCH.assignDataSource("cuid:ARZelWdoCTlDkY.nFZRRlM4", DataSourceType.QUERY, "ZDS_EXERCISE_03");

}

else

{

  DS_SWITCH.assignDataSource("cuid:ARZelWdoCTlDkY.nFZRRlM4", DataSourceType.QUERY, "ZDS_EXERCISE_04");

}

Here, the syntax for the method "assignDataSource()" is as follows:


DS_SWITCH.assignDataSource("<Name of the system you are connecting to>", DataSourceType.QUERY, "<Technical name of the query you want to use>");

The name of the system can be obtained using content assistance (Ctrl + Space) inside the script window.


Thanks and Regards,

Eshwar


Answers (0)