1

The following JavaScript works fine if I pass t_dataSet into DataTable but does not work (e.g no data) if I instead pass this.dataSet.

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;

});

Any ideas on why this is not working as expected?

Patrick Garner
  • 3,201
  • 6
  • 39
  • 58

0 Answers0