How to use a static range and display members according a TOP(x) style query

邮差的信 提交于 2019-12-11 06:11:46

问题


We are trying to add a slider jquery widget, and would like to define a static range, say percentage from 0% to 100%. Then we would like to use the value from the slider in that range as the parameter for the TOP(x), as shown on the picture.

Is this possible? Any hints ?


回答1:


I've created an example report for you, import it using the default [Sales] schema https://drive.google.com/file/d/0B3kSph_LgXizdk9OdnlTWkxHa1U/view?usp=sharing

You could achieve this functionality by using the next sequence:

  1. Create Slider widget
  2. Open a widget options dialog and configure widget properties
  3. Select Query Wizard -> Query Type: Mdx Hierarchies
  4. Add single random hierarchy to bypass validation(it will be replaced)
  5. Setup the default value in Initial Selection (i.e. 10%)
  6. Add a code to your report javascript

viz.filters.Slider.prototype.componentWillMount = function(){
    if(_.isArray(this.props.items)) 
        this.setState({
          entities:new viz.EntityData(this.props.items),
          range:_.map(this.props.defaults,"uniqueName")
        });
}

viz.filters.Slider.prototype.onBuildAllDone = function(){
    if(!_.isEmpty(this.state.range)) {
        this.fireEvent(vizEventType.onSelection,
                       this.createEvent(this.state.range));
        this.fireEvent(vizEventType.onNewLabel,
                       this.createEvent(this.state.range));
    }
} 

function consumeEvent( context, event ) {                                
  if (event.name == 'ic3-report-init') { 
    // Following code will replace a data provider for Slider
    // with generated numbers. But to do so, you'll need UID of
    // the Slider widget, in this example it's "w1"
    var widget = event.value.widgetMgr().getItemById("w1");
    _.assign(widget.builder().guts_, {
      items:_.times(100, function(idx){
        return {
          name:idx + 1 + "%", 
          uniqueName:idx + 1
        }
      })})                                          
  }                                                                      
}


来源:https://stackoverflow.com/questions/38950556/how-to-use-a-static-range-and-display-members-according-a-topx-style-query

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