1 column table fron array (node-dir) either shows each character per cell or all in one cell
1 column table fron array (node-dir) either shows each character per cell or all in one cell
using node.js and electron, creating array using node-dir
Goal is a report of a list of files in a directory so they can be clicked to open.
Expected output - have each element in array on its own line. (3 lines, 1 column)
Actual output1 - either each character is a cell (3 lines, column per character)
Actual output2 - all text in array is in only one cell (1 line, 1 column)
dataset2 value -(a list of files)
console.log(dataset2);
["/home/dl/code/delete/test.txt", "/home/dl/code/delete/three.pop", "/home/dl/code/delete/toiete.e"]
Actual output1
While reading docs it led to me to mozila and it said this
// String
Array.from("foo");
// ["f", "o", "o"]
which was what i was getting when using the data option as
data: dataset2
each column would be a character
Actual output2
so i tried running the array code on data option for table constructor and now all the values are in one cell
data: Array(dataset2),
Code i am using
////node-dir code that creates array to build table from
var dir = require('node-dir');
__dirname = '/home/dl/code/delete'
dir.files(__dirname, function(err, files) {
if (err) throw err;
dataset2 = files
});
//////Datatable constructor using array created above as data option
$('#example2').DataTable( {
data: Array(dataset2),
//dataSrc: "",
"columns": [
{ title: "Number" ,"defaultContent": "<i>Not set</i>"}],
select: {
style: 'multi'
},
"scrollY": "400px",
"paging": false
} );
Answers
When i change data to this i get the same thing only one character. so this looks like 6 rows of one character per column
I read the note about posting a link so when making that I noticed that when i deleted the html and just left the table tag so datatables could do all the table data writing i was left with just one character.
I don't know which html i deleted that made the column only one character long
http://live.datatables.net/juravegu/1/edit
i seem to have got round this by adding columns to array, might have also changed how i create the array