1

When bind datatables with ajax then I datatables column filter checkbox disappear. Here is my code

$('#Table1').dataTable({
    "ajaxSource": "js/Group.JSON"
}).columnFilter({
    sPlaceHolder: "head:after",
    aoColumns: [
         { type: "checkbox", values: null },
         { type: "checkbox", values: null },
         { type: "checkbox", values: null },
         { type: "checkbox", values: null },
         { type: "checkbox", values: null },
         { type: "checkbox", values: null }
    ]
});
2

1 Answer 1

2

Without knowing anything about what is going on - all we know is a comment about "it is not working when I get data from ajax" - and therefore assuming everything else is working great, no news is good news etc; and taken notice of ColumnFilter as being an old buggy plugin built for dataTables 1.9.x with +100 open issues, last fix was nearly 1½ year ago - then I would say this is a simple matter of javascript asynchronicity.

When using chaining

$('#Table1').dataTable({
    //some ajax stuff
}).columnFilter({ .. })

then columnFilter({ .. }) is executed immediately, it does not wait until AJAX has finished its business. The result is that there is no data loaded at the time of the columnFilter initialisation. To prevent this, initialise columnFilter in a callback :

$('#Table1').dataTable({
    fnInitComplete : function() {
        this.columnFilter({
           sPlaceHolder: "head:after",
           ...
        })      
    }
})
Sign up to request clarification or add additional context in comments.

3 Comments

Great!! it is working!! THank you so much davidkonrad :)
I have same issue with updatepanel(asp.net), I put datatable grid inside updatepanel, all are working fine, but when updatepanel called the checkbox column filter disappear, I applied your edited code but no luck
I asked above mentioned question on the following link stackoverflow.com/questions/31587656/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.