简体   繁体   中英

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 ie <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.

make sure you have specified same number of columns.

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

.draw( false );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM