Column rendering return with customized function

Column rendering return with customized function

tianyimiaotianyimiao Posts: 5Questions: 2Answers: 0

I am new in datatable, I am wondering is it possible to do something like that, in rendering column return a html string with customized function removeRow, the aim is to remove the entire row if image cell on this row is unreadable. As example:

this.table = $('#a').DataTable({
            language: {
                    searchPlaceholder: "Search patient"
                },
            "data": data,
            "columns" : [
                   { "data" : "A" },
                   { "data" : "B" },
                   { "data" : "C" },
                   {  
                             "render": function ( data, type, full, meta ) {
                let removeRow = function(e){
                    console.log(e);
                                        //do something
                }
                return "<img onerror='"+removeRow(this)+"' src='https://someimages.jpg'>";
                      },
                   }]
                     });

Any help appreciate!

Answers

  • tianyimiaotianyimiao Posts: 5Questions: 2Answers: 0

    In removeRow function, I am planning to do something like

    let removeRow = function(e){
         this.table
        .row( $(e).parent('tr') )
        .remove()
        .draw();
    }.bind(this);
    
This discussion has been closed.