Hitachi Vantara Pentaho Community Forums
Results 1 to 9 of 9

Thread: Conditionally setting the visible property of an HTML object in CDE

  1. #1
    Join Date
    Aug 2012
    Posts
    13

    Default Conditionally setting the visible property of an HTML object in CDE

    I am making a new dashboard on CDE framework. There is a data query associated with a component having a html object. I want to hide the html object if there is no data available in the HTML query. Is there a way to do that?

  2. #2
    Join Date
    Jul 2007
    Posts
    2,498

    Default

    sure, you can use the postFetch, for instance, somthing like

    function f(data){
    if(data.resultset.length == 0){
    $("#"+this.htmlObject).hide();
    }
    else{
    $("#"+this.htmlObject).show();
    }
    }
    Pedro Alves
    Meet us on ##pentaho, a FreeNode irc channel

  3. #3
    Join Date
    Jul 2013
    Posts
    19

    Default

    Hi guys,

    I want to do something pretty similar, but instead of hiding if there in no data available, I would like to show if a parameter (choice_param) is set to a specific value ('sales'), and otherwise hide the whole component.
    It should also reappear if choice_param is set to 'sales' again (and disappear again if changed etc.).
    Any ideas on the function, and where to put it (post-execution, post-fetch..) ?

    Thanks
    Last edited by rempan; 07-29-2013 at 11:28 AM.

  4. #4
    Join Date
    Nov 2011
    Posts
    1,229

    Default

    Make the component you're trying to hide listen to that parameter.
    Use postchange to test the parameter value and hide the component if necessary.
    Pedro Vale
    --
    CTools Product Development
    http://www.webdetails.pt

  5. #5
    Join Date
    Jul 2013
    Posts
    19

    Default

    SOLVED : just had to change "#" to '#' and put it in the post-execution field
    Thanks, but I can't get it to work...
    Here is the code inside post-change :

    function f() {
    if (Dashboards.getQueryParameter("choice_param") != "sales") {
    $("#"+this.htmlObject).hide();
    } else {
    $("#" + this.htmlObject).show();
    }
    }
    Last edited by rempan; 08-05-2013 at 05:04 AM.

  6. #6
    Join Date
    Jan 2013
    Posts
    135

    Default

    Hi, does anyone know how to do it if MDX query is datasource. For SQL the code above works, for MDX I' getting "No data found".
    Thanks a lot for your help!

  7. #7
    Join Date
    Jan 2013
    Posts
    135

    Default

    Hi, does anyone know how this code should work with MDX query?

    function f(data){
    if(data.resultset.length == 0){
    $("#"+this.htmlObject).hide();
    }
    else{
    $("#"+this.htmlObject).show();
    }
    }

    For SQL it works fine, MDX is saying "No data found".

    thanks a lot for your help!

  8. #8

    Default

    I,
    if you receive this error, probably the problem is the query and not the function.
    I quote an article:
    The SQL query uses the WHERE clause to contain an arbitrary list of items that should (or should not) be returned in the result set. While a long list of conditions in the filter can narrow the scope of the data that is retrieved, there is no requirement that the elements in the clause will produce a clear and concise subset of data.
    and also
    many OLAP tools are incapable of displaying a result set with more than two dimensions.
    You can find the full article here: http://technet.microsoft.com/en-us/l...sql.80%29.aspx
    Maybe you have to change a little bit your query.
    I don't know if this is the real cause of the problem, but I hope this can help you
    Last edited by Duncanmaster; 09-10-2013 at 03:55 AM.

  9. #9
    Join Date
    Sep 2017
    Posts
    18

    Default

    I have tried to follow the guidelines presented in this thread but I haven't had any luck. Any idea if the more recent versions would work differently?

    I have tried using this code in the post-execution as well as in the post-change fields.

    function f(){
    if(dashboard.getParameterValue(PARAM1)=='TS'){
    $('#'+this.htmlObject).show();
    }
    else{
    $('#'+this.htmlObject).hide();
    }
    }

    (And I have a bar chart with the following click action)

    function f(scene) {
    var vars = scene.vars;
    var d = vars.series;
    var text;
    if (d=='Operación'){
    text='OP';
    }else{
    text='TS';
    }
    dashboard.fireChange('PARAM1',text);

    }

    And the charts are listening to the PARAM1 parameter.
    Last edited by qwerty123; 10-18-2017 at 03:18 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.