简体   繁体   中英

How to get value of selected parameter on parameter change event in tableau Javascript API

I have following code can anyone help me upon this:

  $(document).ready( 
    function(){     
        viz = loadReport('<?php echo $url; ?>', 'viz', $(window).height()-$('#viz').offset().top-10, '100%','<?php echo ($login->hide_toolbar==1?true:false); ?>','<?php echo ($login->hide_tabs==1?true:false); ?>', function(){
            viz.addEventListener(tableau.TableauEventName.TAB_SWITCH, onTabSwitch);
            viz.addEventListener(tableau.TableauEventName.PARAMETER_VALUE_CHANGE, onParameterValueChange);
            prepareSavedViewState();
        });

    }
);

 function onParameterValueChange(e){
    //e.preventDefault();
    //alert(e.getEventName());
    //alert(e.getParameterName());
    //alert(e.getParameterName().getCurrentValue());
    //alert(e.getCurrentValue());
    //alert(e.Parameter.getCurrentValue());
    //alert(Parameter.getCurrentValue());
    alert(e.getParameterAsync().getCurrentValue());
}

I am trying to get value of selected parameter of tableau dashboard on live server but not getting the value. Actually parameter object is working fine but not understanding how to get value.

You got the event wiring right. In your onParameterValueChange function you need to call getParameterAsync and the used the returned promise object to get the actual parameter value.

See this sample:

function onParameterValueChange(e){
   e.getParameterAsync().then(function(param){
      alert(''+param.getName()
              +' of Type '+param.getDataType()
              +' has value '+param.getCurrentValue().formattedValue);
   });
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM