Bijan
Bijan

Reputation: 8586

DataTables Add Row with special data fields

I am having some trouble adding a row to an already populated table.

Here is my current code that I am working with. I am using the following code to add a row:

t.row.add([
    '<td class="truncate"><a class="tooltipped" data-delay="50" data-html="true" data-position="bottom" data-tooltip="Tooltip text" href="http://testing.com" target="_blank">New Row</a></td>',
    '<td>999</td>',
    '<td><i aria-hidden="true" class="fa fa-envelope fa-lg" title="email"></i></td>',
    '<td>United States</td>',
    '<td>2019-12-31</td>',
    '<td data-order="1478498400">5 Days 1 Hours</td>',
    '<td><a onclick="markAsVisited(\'xxxxx\')" style="cursor: hand;"><i class="fa fa-times fa-lg" style="color:red;"></i></a></td>'
]).draw();

However I keep getting this error. Also the column under 'Ends In' never displays the data, what is the problem with this?

The table that I have has special data-field's like data-order that I use to help sorting. My preferred method of adding a row would be to just pass in all the rows contents i.e. <tr id='abcde'><td class=......></td><td>...</td>etc</tr> and just have it create the new row with all the code I passed in.

Upvotes: 0

Views: 54

Answers (1)

Ghost Developer
Ghost Developer

Reputation: 1433

make sure you have specified same number of columns.

to sort and then redraw the table maintaining current paging position, try

.draw( false );

Upvotes: 1

Related Questions