问题
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:
- Create Slider widget
- Open a widget options dialog and configure widget properties
- Select Query Wizard -> Query Type: Mdx Hierarchies
- Add single random hierarchy to bypass validation(it will be replaced)
- Setup the default value in Initial Selection (i.e. 10%)
- 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