简体   繁体   English

如何在Tableau Javascript API中的参数更改事件上获取所选参数的值

[英]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. 我正在尝试获取实时服务器上Tableau仪表板的选定参数的值,但没有得到该值。 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. onParameterValueChange函数中,您需要调用getParameterAsync并使用返回的promise对象来获取实际参数值。

See this sample: 看到这个例子:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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