Add Row To Datatable at Runtime


Can someone please point me in the right direction.

I have looked at the DataTables website and found what I think is the right thing:

I’ve studied the including sample file, but with no code to add rows I’m just trying different things and wasting a lot of time.

My code at the moment, which isn’t working looks like this.

Function FillDataTable()

    dt.settings.columns = columns1 = data1
End Function

Function Button2_onclick()
  table = $("dt").DataTable()
End Function

Any help appreciated. I know DataTables is a big topic and NSBasic can’t cover everything, but some more examples on using the datatable would be great.


Afer a couple of hours of mucking around, this seems to achieve what I want, hopefully it helps someone else out:

I’m using BASIC, so it’s wrapped in Javascript

Function Button2_onclick()
    var t = $('#dt').DataTable();
    t.row.add( [
        'data 2',
        'data 3',
        'data 4',
    ] ).draw( false );

  End JavaScript

End Function