Pentaho CDE reset parameter

爱⌒轻易说出口 提交于 2020-01-11 14:06:20

问题


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:


There are two issues you need to solve:

  1. Adding default values for the selectors
  2. Adding a button that resets these selectors to their default value

For 1 I would go for something like this:

  • Set the SQL query for the selectors datasource like this:

    SELECT '%' FROM [ANY TABLE] UNION [YOUR EXISTING QUERY]

    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.

Now for 2 you need some preparation to make things work:

  • 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.

  • The final trick is just to add a button which will trigger this function. You can use plain old HTML+JS syntax.

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!



来源:https://stackoverflow.com/questions/37474549/pentaho-cde-reset-parameter

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