How to add a “select all” option to select component in CDE?

寵の児 提交于 2019-12-11 05:49:23

问题


I have a select component on my dashboard and i want to add a "select all" option to be a default value of this selector. The data source for this select component is SQL. Can anyone help?


回答1:


To add select all option as a default value i will explain you with an example.

consider i have two distinct rows in one column(eg: Category is the column name and there are two rows in that column "Billable","Non-Billable") selecting either of this two is possible or selecting both using multiselect can also be done.suppose if i want to add "All Category" as third row in Category column and use that to select both.below is the procedure and screen shot.

In Components Panel:

under Generic select custom Parameter Name : Param1 javascript code : "All Category" rest default values

under Selects select selectmulti Component

Name: select1 Parameter: Param1 Listeners: Param1 Datasource: Billability_query1(location where sql query to select component is wriiten) Htmlobject: place holder to display select component. rest all default values

Datasource Panel:

under Sql queries select sqlover sql jdbc

Query:

Select 'All Category' as Category from pentaho_output_report UNION Select Category from pentaho_output_report;

Parameters: Param1

Click here for screen shot

hope it would be helpful.




回答2:


A second solution :

If you have a selector which allow you to choose the Division (for example)

By default, the query of the selector will be something like :

with member [Measures].[Name] as '[Division].CurrentMember.UniqueName' select TopCount( filter({Descendants([Division].[All Divisions] ,[Division].[Division])}, not isempty(([Division].CurrentMember)) ) , 50) on ROWS, 
 {[Measures].[Name]} on Columns 
 from YOUR_SOURCE

You can adapt this by :

with member [Measures].[Name] as '[Division].CurrentMember.UniqueName' select  {Descendants([Division].[All Divisions])}  on ROWS, 
 {[Measures].[Name]} on Columns 
 from YOUR_SOURCE

This way, the first item will be "All Division" and the others will follow. Then you can put in the chart parameter "[Division].[All Division]" to specify that you want the first one as parameter

Hope this will help



来源:https://stackoverflow.com/questions/38213674/how-to-add-a-select-all-option-to-select-component-in-cde

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!