Hi,
i'm also new to custom controls, but i think i've figured out while yours isnt't working:
In the Cognos Report you have to add a data set to your custom control.
- click on the "(+)"-Symbol
- add a query calculation to the categories (e.g. Name: dummy; Expression 1)
additionally alter your code:
var m_dataSet = this.dataSet;
$(function () {
$('#datatable_example').DataTable( {
data: m_dataSet,
columns: [{ title: "Name" }]
});
});
------------------------------
bj ml
------------------------------
Original Message:
Sent: Fri March 22, 2019 07:06 AM
From: Patrick Garner
Subject: IBM Cognos Analytics with jQuery/DataTables drawn or setData function problem
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, 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
------------------------------
#CognosAnalyticswithWatson