Search code examples
htmleventsolapiccubeiccube-reporting

How to fire an event from html dropdown in icCube


I have the following code for a dropdown menu that lists month.

<select>
 {{ for( var col = 0; col < d.colCount; col++ ) { }}  <!-- This is the way adding js code -->
<option value="[Time].[Month].[month].[{{=d.colLabel(col) }}]">{{=d.colLabel(col) }}</option>
{{ } }}

When the user selects an option, an event called month should be fired. How can i do that in icCube OLAP.


Solution

  • There are several possibilities how you can achieve needed functionality

    On Cell Click Functionality

    There is special attribute that allows to click on specific data cell called ic3a read more...

    <select>
    {{ for( var col = 0; col < d.colCount; col++ ) { }}
        <option ic3a="fireClick(0,{{=col}})" value="[Time].[Month].[month].[{{=d.colLabel(col) }}]">
            {{=d.colLabel(col) }}
        </option>
    {{ } }}
    </select>
    

    You should specify event name for "on Cell Click" : "month" in options' "Events" tab.

    External Code

    If you have access to ic3Reporting instance

    for example:

    var ic3Application = ic3.startReport(options);
    

    and want to handle current functionality with code on your site you can fire ic3-internal events in such way :

    <script type="text/javascript">
        //get ic3application instance
    
        var ic3Application = ic3.startReport(options);
    
        function selectMonth (value) {
            ic3Application.fireEvent("month", new viz.event.ValueEvent(value))
        }    
    </script>
    <select onchange="selectMonth(this.value)">  
        {{ for( var col = 0; col < d.colCount; col++ ) { }}
        <!-- This is the way adding js code -->
        <option value="[Time].[Month].[month].[{{=d.colLabel(col) }}]">
           {{=d.colLabel(col)}}
        </option>
        {{ } }}
    </select>
    

    ic3 FILTER Widget

    Suitable when you want to get list of predefined months from cube. Add MDX Filters > ICCUBE > Drop-down widget and configure it's settings in needed way.

    ic3 ACTION Widget

    This option is suitable when you have specific list of months.

    Just create Tools/Utilities > Actions > Drop-down widget and provide needed months at "Items Wizard" options' tab and set "month" as value to "on Selection" event name at "Events" tab.