Question

I have a datatable with few rows, I want to add new row in table :

  var oTable = $('#StudentsTable').dataTable();
  Table2.fnStandingRedraw();

when I init the dataTable I add :

            "bProcessing": true,
            "bServerSide": true,
            "bDestroy": true,
            "fnFilter": true,
            'bLengthChange': true,
            'bPaginate': true,
            'bStandingRedraw': true,

after ajax submit I want to redrow the table:

submitHandler: function(form) {
            var $modal = $('#ajax-modal');
            $modal.modal('loading');
            $(form).ajaxSubmit({
                dataType: 'json',
                success: function(result) {
                    if (result.Success) {
                        if (result.Data.Action == "add") {
                            var oTable2 = $('#StudentsTable').dataTable();
/*=>here is Call redraw */  oTable2.fnStandingRedraw();
                        }

here it give me error: Uncaught TypeError: Object [object Object] has no method 'fnStandingRedraw'

some suggestions?

Was it helpful?

Solution

You forgot to include the fnStandingRedraw plugin. Make sure to add it right after the Datatables' script file.

Copying and pasting the snippet on top of your script would work too, though putting it on a separate file may prove to be more organized and re-usable. Or you can also concatenate this snippet at the end of the uncompressed Datatables source file and minify it altogether, so it will always be available when the Datatables script is included.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top