+
+ function regular_set_message ($table, $tbody, message) {
+ $tbody.html("<tr><td>"+message+"</td></tr>");
+ }
+
+ function regular_update_table ($table, $tbody, rows, key) {
+ if (simplelist_debug) console.log('regular_update_table ' + rows.length + " rows");
+ var html=$.map(rows, function (row) { return html_row ( cell (key, row[key])); }).join();
+ $tbody.html(html);
+ }
+
+ function datatables_set_message ($table, $tbody, message) {
+ $table.dataTable().fnClearTable();
+ $table.dataTable().fnAddData( [ message ] );
+ $table.dataTable().fnDraw();
+ }
+
+ function datatables_update_table ($table, $tbody, rows, key) {
+ if (simplelist_debug) console.log('datatables_update_table ' + rows.length + " rows");
+ $table.dataTable().fnClearTable();
+ // the lambda here returns a [[]] because $.map is kind of broken; as per the doc:
+ // The function can return any value to add to the array. A returned array will be flattened into the resulting array.
+ // this is wrong indeed so let's work around that
+ $table.dataTable().fnAddData( $.map(rows, function (row) { return [[ cell (key,row[key]) ]] }) );
+ $table.dataTable().fnDraw();
+ }
+
+ function html_row (cell) { return "<tr><td class='simplelist'>"+cell+"</td></tr>"; }