How to add a select all option to select component

2019-03-01 19:02发布

for a students projects we are working with Pentaho CDE to create a dashboard. At first it works fine, but now we are hanging at the point adding more than one Select Component. We inserted the Parameters of the Select Components to the SQL-Queries in the Where statement but now we have the problem, that it is not possible to select all elements in one select component and only one in the others. The sample space is getting smaller and smaller the more parameters we add because we can't find out how to select all option in one select component and send this all to the query. Is it possible in CDE to add an "select all elements option" to the select component? Or even to deactivate a select component and send this deactivation to the SQL-Query?

We noticed that there is a multiple select component but we were not able to handle the custom parameter needed for it. It would be fine if it works with the select components.

Thanks in advance for your support.

3条回答
太酷不给撩
2楼-- · 2019-03-01 19:41

If you dont want use like.

SELECT * from table_name where column_name = case when ${param} = 'ALL' then column_name else ${param} end
查看更多
欢心
3楼-- · 2019-03-01 19:54

Two approaches:

  1. On your single select query add (possibly hardcoding) a "All" option and have some JS logic learn how to handle it;

  2. Use multi select components. However, bear in mind that the parameter values on a multi select component are stored as an array in javascript, whereas the parameter value will be passed as a comma separated list to the query. So, if you want to use a multi select parameter in a SQL query you will most likely use it inside a IN condition.

Finally, check your pentaho.log file. The errors and exceptions will be logged there.

查看更多
男人必须洒脱
4楼-- · 2019-03-01 20:03

Use SQL expression CASE:

SELECT * FROM table WHERE cities LIKE (case when ${city} = 'ALL' then '%' ELSE ${city} end)

查看更多
登录 后发表回答