Delete single choosen row in Angular 4

Delete single choosen row in Angular 4

VoroshilovMaxVoroshilovMax Posts: 1Questions: 1Answers: 0

Hi everybody!
I use Angular 4 with your DataTables, on each row I have delete button

and I can`t choose good code for delete one single row!

I use Angular code from: site
and my code looks like:

        ##              option(){
        ##         let oldStart = 0;
        ##         this.dtOptions = {
        ##           pagingType: 'full_numbers',
        ##           lengthMenu: [[25, 50, -1], [25, 50, "All"]],
        ##           "order": [[ 2, "desc" ]],
        ##           dom: '<"top"if>rt<"bottom"lp><"clear">',
        ##           scrollX: true,
        ##           language: {
        ##             search: "_INPUT_",
        ##             searchPlaceholder: "Search records",
        ##             },
        ##             drawCallback: function (o) {
        ##               var newStart = this.api().page.info().start;
        ##         
        ##               if ( newStart != oldStart ) {
        ##                   var targetOffset = $('#like-table').offset().top;
        ##                   $('html,body').animate({scrollTop: targetOffset}, 500);
        ##                   oldStart = newStart;
        ##               }
        ##           },  
        ##         };
        ##       }

For deleting row I used "splice()" methods from TypeScript. It's deleted chosen row but after that design in tables looks like broken! A light line, a dark line and again a dark line .... I think you understood me. And the quantity in the line "Show" is not correct.

I tryed to use jQuery code but I don`t know how to initialize dataTables...

    $("document").ready(function () {
        oTable = $("#myTable").dataTable();
    });
        $('.glyphicon-minus').on("click", function() {
            oTable.row($(this).closest("tr").get(0)).remove().draw();
        });

This code show me error alert. That I try to initialize table two times...

PLEASE HELP... %)

Answers

  • allanallan Posts: 63,550Questions: 1Answers: 10,476 Site admin

    That code should be giving you an error message stating that "row" is not a function - see the top FAQ for why that is.

    Allan

This discussion has been closed.