I have one way to do it. I use a jsp and pass the column names and data in on a bean. It works with a varying number of columns and data values as long as the number of data values in each row matches the number of columns in the header:
Query Results
var dataVar = <%= viewerData %>;
var colNames = <%= columnNames %>;
where the view data is a string that looks like: [["val1", "val2", "val3"],["val1a", "val2a", "val3a"]]"
and the columnNames looks like [{sTitle:"col1"},{sTitle:"Col2"},{sTitle:"Col3"}]
The problem I have had is getting the horizontal scrolling to work. No matter what vaues I use for xScrollx and sScrollXInner it never displays the horizontal scroll bar. If I add columns it just makes the displayed columns smaller.
Replies
Query Results
var dataVar = <%= viewerData %>;
var colNames = <%= columnNames %>;
$(document).ready(function() {
$('#exampleTable').dataTable({
sPaginationType:"full_numbers",
bJQueryUI: true,
bScrollAutoCss: true,
aoColumns: colNames,
aaData: dataVar,
bScrollCollapse: true,
sScrollx: "100%",
sScrollXInner: "600%"
});
} );
where the view data is a string that looks like: [["val1", "val2", "val3"],["val1a", "val2a", "val3a"]]"
and the columnNames looks like [{sTitle:"col1"},{sTitle:"Col2"},{sTitle:"Col3"}]
The problem I have had is getting the horizontal scrolling to work. No matter what vaues I use for xScrollx and sScrollXInner it never displays the horizontal scroll bar. If I add columns it just makes the displayed columns smaller.