define mData column on condition

define mData column on condition

akhilkhareakhilkhare Posts: 6Questions: 2Answers: 0

We have a scenario where we need to hide the column based on data shows in row. we did a trick like passed conditional JSON from server, but because we have column define in datatable its thrown an error.

Is there any way to hide a column based on row cell data?

Answers

  • akhilkhareakhilkhare Posts: 6Questions: 2Answers: 0

    Please reply asap..we stuck due to this

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    Is there any way to hide a column based on row cell data?

    I would suggest using the initComplete callback or init event.

    Please reply asap..we stuck due to this

    Priority support is available if you require urgent help.

    Allan

  • akhilkhareakhilkhare Posts: 6Questions: 2Answers: 0

    Thanks Allan, its worked for me

    "createdRow": function (row, data, index) {
    isVisible = false;
    }
    "initComplete": function (settings, json) {

                    var tmpTable = $("#example").dataTable();
                    tmpTable.fnSetColumnVis(0, isVisible );
    
                }
    
This discussion has been closed.