1

I am using jQuery Datatable with server side processing, here is my code. It works fine nut as soon as i add one more column for actions button in it, it just stops rendering. Any help will be appreciated.

 $("#table1").dataTable({

        "processing": true,
        "serverSide": true,
        "info": true,
        "lengthMenu": [[5, 35, 50, -1], [5, 35, 50, "All"]],
        "ajax": {
            "url": "/Customer/customers",
            "type": "POST"
        },
        "columns": [
            { "data": "displayName", "orderable": true },
            { "data": "email", "orderable": true },
            { "data": "state", "orderable": true },                
            {
                "data": "licenses", "orderable": true,
                "render": function (data, type, row) {
                    if (type === 'display') {
                        if (data > 0)
                            return '<i class="fa fa-check" aria-hidden="true"></i>';
                        else
                            return '<i class="fa fa-times" aria-hidden="true"></i>';
                    }
                    return data;
                }
            },
        ]           
    });       

Here is another column with action buttons i am adding after licenses in column array.

            {
                "data": null, "orderable": false, "render": function (data, type, row) { return '<a href="' + data + '">Download</a>'; }
            },

Can anyone tell me what is going wrong here?

1 Answer 1

1

In the html page, if you have less or columns than the number of columns that you are rendering using ajax, it will show error. As you are saying that it shows error when one more column is added, I think the issue is that there is less column in your html page. If you fix the number of columns, I think it will work.

Sign up to request clarification or add additional context in comments.

1 Comment

The number of columns are same though i have used "colspan" in last header

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.