1

I'm, using ajax request to get data to make my datatables, but I need change de columns with html's tags and content.

My datatables resquest is:

var oTable1 = $('#sample-table-2').dataTable({
    "language": {
        "url": "/assets/js/Portuguese-Brasil.json"
    },
    "aoColumnDefs": [{
        "bSortable": true, "aTargets": [0, 1, 2],
        "bSortable": false, "aTargets": [1, 2]
    }],
    "ajax": {
        "url": "/Clientes/GetClientes/",
        "dataSrc": "",
        "dataType": "json",                   
    },
    "columns": [
        { "data": "Nome" },
        { "data": "<strong>StatusDesc</strong>" },
        { "data": "<span>StatusDesc</span>" },
    ],                               
});

But when this table is render, the html code inside columns doen't work.

Thank you!

2 Answers 2

2

Use sTitle

{ "sTitle": "offer name<span style='display:none;'>offer_name</span>",  
  "data": "offer_name"
},
Sign up to request clarification or add additional context in comments.

2 Comments

Yes, but title can also be used -> datatables.net/reference/option/columns.title sTitle is the old hungarian notation naming style (but still works)
@sergiodebcn is possible send array inside data, and pass two or more data for one sTitle?!
0

I think you can't do that as you want it to do (at least, if I understood your "question" correctly). The datatables already have classes for each element, e.g. the column headers are usually called DataTables_sort_wrapper. So what comes to mind is, you could change the appearance of those column headers with css and/or jQuery. E.g. you can find the n'th column appearance by using the jQuery .eq() function

$(".DataTables_sort_wrapper").eq(n).css(...)

Hope this helps.

Cheers

Comments

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.