问题
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