绘制了jQuery / DataTables或setData函数问题的IBM Cognos Analytics

时间:2019-03-21 21:05:15

标签: cognos cognos-bi cognos-11

如果我将t_dataSet传递到DataTable,则以下JavaScript可以正常工作,但是如果我却传递this.dataSet,则以下JavaScript无法工作(例如,无数据)。

define( ['jquery', 'https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js'], function($, Datatables) {
"use strict";

function DatatablesSimpleList() {}

DatatablesSimpleList.prototype.draw = function( oControlHost ) {

    let htmlElement = oControlHost.container;
    htmlElement.innerHTML = '<table id="datatable_example" class="display" width="100%"></table>';

    var t_dataSet = [
        [ "Tiger Nixon" ],
        [ "Garrett Winters"],
        [ "Ashton Cox"]
    ];

    $(function () {
        $('#datatable_example').DataTable({
            data: t_dataSet,        // this works
            //data: this.dataSet,   // this does not work
            columns: [{ title: "Name" }]
        });

    });
};

DatatablesSimpleList.prototype.setData = function( oControlHost, oDataStore ) {

    this.dataSet = [
        [ "Tiger Nixon" ],
        [ "Garrett Winters"],
        [ "Ashton Cox"]
    ];
};

return DatatablesSimpleList;

});

关于为什么此方法无法按预期工作的任何想法?

0 个答案:

没有答案