row.remove is not working

row.remove is not working

rooshakrooshak Posts: 2Questions: 1Answers: 0
edited August 2014 in Free community support

http://debug.datatables.net/etixon - my debug link,

var otherTable = function(){
            var t = $('#otherTable').DataTable({
                "info": false,
                "paging": false,
                "searching": false,
                "ordering": false
            });
            var counter = 0;
            $(document).on('click', '#add-row-other', function (e) {
                e.preventDefault();
                t.row.add( [
                    '<input type="text" class="form-control" name="org_name['+[counter]+']" >',
                    '<input type="text" class="form-control" name="org_addr['+[counter]+']" >',
                    '<input type="text" class="form-control" name="org_amount['+[counter]+']" >',
                    '<button type="button" id="delete-row" class="btn btn-danger delete"><i class="glyphicon glyphicon-trash"></i> <span>Delete</span></button>',
                ] ).draw();
         
                counter++;
            });

            $('#otherTable').on('click', '#delete-row', function (e) {
                e.preventDefault();
                //console.log(t.row);
                t.row.remove($(this).parents('tr')).draw();
            });
        };

TypeError: t.row.remove is not a function

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,858Questions: 1Answers: 10,344 Site admin
    Answer ✓

    TypeError: t.row.remove is not a function

    It isn't :-). You want row().remove() - i.e. - t.row( ... ).remove().draw();.

    Btw, the code above suggests you might have more than one element with the ID #delete-row - which isn't going work. Ids must be unique in HTML.

    Allan

  • rooshakrooshak Posts: 2Questions: 1Answers: 0

    Thank you allan.. I made a silly mistake. I just tested this using one row that's why I used an ID..

This discussion has been closed.