remove sort icons when using row.add function

remove sort icons when using row.add function

jcarvalhojcarvalho Posts: 13Questions: 3Answers: 0

Hi guys, I have this code to add rows to a datatable:

    function atualizar_dtLinhaFatura( dados )
    {         
        dtLinhaFatura.clear().draw();        
        $.each(dados.data, function(index, val)
        {
            //alert(val.ref);
            dtLinhaFatura.row.add([
                val.ref,
                val.design,
                "<input type='text' class='form-control txtQdtLinhaFatura' value='" +  val.qtd + "'>",
                val.pvf,
                val.iva,
                val.pvf_total,
                val.desconto,
                val.PVF_Liq_Total,            
                {
                    data :'',render: function ( data, type, row, meta )
                        {
                            return "<button class='btn btn-info btn-sm remove-linhafatura'><i class='fa fa-minus'></button>";
                        },
                        'bSortable': false,
                },            
            ]).draw();
        });
    }

All is working but last column don't. I am getting [object Object]. Can someone point me the right way to remove the srting icons when adding rows? Many thanks!

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923
    Answer ✓

    This code:

                {
                    data :'',render: function ( data, type, row, meta )
                        {
                            return "<button class='btn btn-info btn-sm remove-linhafatura'><i class='fa fa-minus'></button>";
                        },
                        'bSortable': false,
                },           
    

    Goes into either your columns or columnDefs option. The row.add() API is looking for an array of values but is not expecting config options.

    Kevin

This discussion has been closed.