Some difficults with update data.

Some difficults with update data.

delphiecdelphiec Posts: 2Questions: 1Answers: 1

Hello, I tryied to update data, but get an error, when table no data while first initialization.
For example:


var table = $('#table_' + id).DataTable({//Construct table buttons: [ { extend: 'colvis', text: '<i class="icon-grid7"></i> <span class="caret"></span>', className: 'btn bg-blue btn-icon', }, { extend: 'copyHtml5', className: 'btn btn-default', text: '<i class="icon-copy"></i>', exportOptions: { columns: ':visible' } }, { extend: 'excelHtml5', className: 'btn btn-default', text: '<i class="icon-file-excel"></i>', exportOptions: { columns: ':visible' } }, { extend: 'pdfHtml5', className: 'btn btn-default', text: '<i class="icon-file-pdf"></i>', exportOptions: { columns: ':visible' } }, { extend: 'csvHtml5', className: 'btn btn-default', text: '<i class="icon-file-spreadsheet"></i>', extension: '.csv' }, { extend: 'print', className: 'btn btn-default', text: '<i class="icon-printer"></i>', }, { text: '<i class="icon-plus3"></i>', className: 'btn bg-teal-400', action: function (e, dt, node, config) { var data = {}; data.id = '0'; data.table = id; data.tableMode = 'onEdit'; getTableModal(id, getData('tableData', data)); } } ], stateSave: true, columns: cols, data: tableData, columnDefs: colsDefs, });

tableData, cols, colsDefs content in attachment.

Then I try to update data:

table.clear().draw();
table.rows.add(tableData);
table.draw();

tableData and error on the screenshot 2.

Most likely not defined: columns and columnDefs
If this is the case, I will be happy if someone give me advice, how to do it dynamically?

This question has an accepted answers - jump to answer

Answers

  • delphiecdelphiec Posts: 2Questions: 1Answers: 1
    Answer ✓

    The question can be closed, as it was really required in the absence of data, to fill in the column headers.

This discussion has been closed.