Pentaho CDE重置参数 [英] Pentaho CDE reset parameter
问题描述
我有一个数据表组件和七个与之相关的选择器.我想用一个重置按钮将所有选择器重置为默认值. 我的数据源是SQL数据库,所以我在这些选择器中没有选择全部"选项.有什么办法可以实现?
I have a data table component and seven multiple selectors related to it. And i want to reset all selectors to default value with a reset button. My data source is SQL database, so i don't have a select "All" option in these selector. Is there any way to make it happen?
推荐答案
您需要解决两个问题:
- 为选择器添加默认值
- 添加将这些选择器重置为其默认值的按钮
对于 1 ,我会选择这样的内容:
For 1 I would go for something like this:
-
为选择器数据源设置SQL查询,如下所示:
Set the SQL query for the selectors datasource like this:
SELECT '%' FROM [ANY TABLE] UNION [YOUR EXISTING QUERY]
这样,您还将拥有值%
作为可能的选项.这将是您的默认值,但是您的DataTable查询必须在WHERE
子句中使用LIKE ${YOUR_PARAMETER}
才能起作用.
This way you will also have the value %
as a possible option. This will be your default value, but your DataTable query will have to use LIKE ${YOUR_PARAMETER}
in the WHERE
clause for it to work.
现在 2 ,您需要做一些准备工作才能使工作正常:
Now for 2 you need some preparation to make things work:
-
使选择的组件收听与它们设置的参数相同.通过这种方式更改参数也将触发选择UI的更新.
Make your select components listen to the same parameter they are setting. This way changing a parameter will also trigger the update of the select UI.
添加一个脚本组件,以便您可以编写函数以重置其中的参数.这样,您可以在按下按钮时调用此函数.
Add a Script component so you can write the function to reset the parameters in it. This way, you can call this function on the event of a button press.
最后一个技巧是添加一个按钮,该按钮将触发此功能.您可以使用普通的旧HTML + JS语法.
The final trick is just to add a button which will trigger this function. You can use plain old HTML+JS syntax.
功能+ HTML按钮将如下所示:
The function + HTML button would be something like this:
function resetParameters() {
// The names of the parameters to be reset
var parameters = [
'param1',
'param2',
...
];
// Iterate them
parameters.each(function(param) {
// Fire the change to the default value.
// The selects are listening for this and will change
// the selected item accordingly
Dashboards.fireChange(param, '%');
});
}
<button onclick="resetParameters()">Reset</button>
我还没有尝试过,但应该可以解决问题!
I haven't tried but it should do the trick!
这篇关于Pentaho CDE重置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!