Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate Table with only one Column

Hello i try to generate a table with only one column. So my Links get displayed in only one column.

Here is my function:

    function createTableForPdfFiles() {

        //To Create The Table
        var table = document.createElement("table");
        table.setAttribute('id', 'pdfTable');
        table.setAttribute('class', 'AANTable');

        // insert Title Row
        var TitleRow = table.insertRow();
        var cell = TitleRow.insertCell(); 
        cell.setAttribute('class', 'AANTitleRow');
        cell.setAttribute('colSpan', pdfFiles.length + 1);
        cell.appendChild(document.createTextNode("Datenblätter"));

        //Insert Table Rows
        var pdfRow = table.insertRow();
        var cell = pdfRow.insertCell(); //Where the PDF´s are displayed
        cell.setAttribute('class', 'AANPdfRow');

        for (var i = 0; i < pdfFiles.length; i++) {
            var cell = pdfRow.insertCell();
            var link = document.createElement("a");
            link.setAttribute("href", "www.test.at" + pdfFiles[i].Link);
            var linktext = document.createTextNode(pdfFiles[i].Link);
            link.appendChild(linktext);
            cell.appendChild(link);
            cell.setAttribute('class', 'AANPdfCell');

        }

        $("#divTable").append(table);
}

Right now it looks like: Wrong Table

But i want it to look like: good Table

So how i can i make that possibe? I tried to add another Row to the table but the debugger says not supported...... Any help would be really great.

thanks for your Time.

like image 860
opelhatza Avatar asked Jun 23 '26 22:06

opelhatza


1 Answers

You have to create anew row foer each pdf.

Hae to put this

var pdfRow = table.insertRow();
var cell = pdfRow.insertCell(); //Where the PDF´s are displayed
cell.setAttribute('class', 'AANPdfRow');

Inside the for

take a look at this -> fiddle

like image 145
rick Avatar answered Jun 26 '26 10:06

rick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!