• 与CDF中的TableComponent组件交互 转自Pedro Alves on Business Intelligence


    原文在blogspot上,blogspot已经被墙了。可惜,可惜。

    Interacting with the TableComponent

    It's been usual to see someone asking for interaction with the TableComponent in CDF. While it's true that we don't support that out of the box, it's incredibly easy to add it. Well, maybe not incredibly easy to everyone, but that's what blogs are for :)


    To achieve that we'll use the amazingly useful postExecution function. It allows us to execute whatever we want after the component is rendered. Since CDF internally uses JQuery we have almost no restrictions to what we can do.


    We'll use the bind and live functions of jquery. Let's define our click function:


    var clickFunction = function(){
    alert("You clicked on: " + $(this).text())
    }




    And in our postExecution we'll add a call for it. I'll use the sample in the documentation


    var topTenCustomers =
    {
    name: "topTenCustomers",
    type: "tableComponent",
    chartDefinition: MetaLayerHome2.topTenCustomerDefinition,
    htmlObject: "sampleObject",
    executeAtStart: true,
    postExecution: function(){
    var cols = $("#sampleObject td:nth-child(1)");
    cols.die("click");
    cols.live("click",clickFunction);
    }
    };



    Some explanations. With the help of selectors we selected every first row (index on nth-child starts at 1). We can select whatever column(s) we want. Then I attached the clickFunction to the click event on those cells.

    The reason I used live instead of bind is subtle - this way, when we change pages or filter within our component it will still work.

    And that's it. In a real-world scenario we'd probably replace the alert() with something like the Dashboards.fireChange function like we do in charts, but you get the idea.

    Of course we can play a bit around this idea. Here's my final alternative to the tablecomponent component reference example:





    var MetaLayerHome2 = {
    topTenCustomerDefinition: {
    colHeaders: ["Customers","Sales"],
    colTypes: ['string','numeric'],
    colFormats: [null,'%.0f'],
    queryType: 'mdx',
    displayLength: 5,

    catalog: 'solution:steel-wheels/analysis/steelwheels.mondrian.xml',
    jndi: "SampleData",
    query: function(){

    var query = "select NON EMPTY {[Measures].[Sales]} ON COLUMNS,"+
    " NON EMPTY TopCount([Customers].[All Customers].Children, 10.0, [Measures].[Sales]) " +
    " ON ROWS from [SteelWheelsSales]"
    return query;
    }
    }
    };

    var mouseoverFunction = function(){
    var oldColor = $(this).css("color");
    $(this).data("oldColor",oldColor);
    $(this).css("color","red");
    $(this).css("cursor","pointer");
    }

    var mouseoutFunction = function(){
    $(this).css("color",$(this).data("oldColor"));
    $(this).css("cursor","default");
    }

    var clickFunction = function(){
    alert("You clicked on: " + $(this).text())
    }

    var topTenCustomers =
    {
    name: "topTenCustomers",
    type: "tableComponent",
    chartDefinition: MetaLayerHome2.topTenCustomerDefinition,
    htmlObject: "sampleObject",
    executeAtStart: true,
    postExecution: function(){
    var cols = $("#sampleObject td:nth-child(1)");
    cols.die("click");
    cols.die("mouseover");
    cols.die("mouseout");
    cols.live("click",clickFunction);
    cols.live("mouseover",mouseoverFunction);
    cols.live("mouseout",mouseoutFunction);
    }
    };
    Dashboards.init([topTenCustomers]);

  • 相关阅读:
    Linux内核异常处理体系结构详解(一)【转】
    一则利用内核漏洞获取root权限的案例【转】
    linux tracepoint用法【转】
    实现PC视频播放最强画质教程( Potplayer播放器+MADVR插件)【转】
    getopt_long函数使用【转】
    用Qemu运行/调试arm linux【转】
    linux内核input子系统解析【转】
    Linux input子系统 io控制字段【转】
    Linux设备树语法详解【转】
    of_alias_get_id 函数与设备树中aliases节点的关系【转】
  • 原文地址:https://www.cnblogs.com/iammatthew/p/1803921.html
Copyright © 2020-2023  润新知