Read options from html

Read options from html

NewcomaNewcoma Posts: 24Questions: 0Answers: 0
edited August 2013 in General
Hello

Can dataTables read options from the individual table like a classname for example? I want to disable sorting on some columns on individual tables without repeating the

$('.tablesorter-js').dataTable({
"aoColumns": [
{ "bSortable": false },
null,
null,
null,
null
]});

Replies

  • allanallan Posts: 63,504Questions: 1Answers: 10,471 Site admin
    Currently you would need to do the DOM reading yourself and built the columns array as needed. I've been planning on making a plug-in which will do this for years, but never yet got around to it! Perhaps post 1.10... :-)

    Allan
  • NewcomaNewcoma Posts: 24Questions: 0Answers: 0
    Ok I will see what I can come up with
  • NewcomaNewcoma Posts: 24Questions: 0Answers: 0
    This is how I did it

    Put the class no-tablesorter-js on the th element you dont want sortable.

    var colList = [];
    $('.tablesorter-js > thead th').each(function(i){

    if (!$(this).hasClass('no-tablesorter-js')) {
    colList.push(null);
    } else {
    colList.push({'bSortable': false });
    }
    });

    $('.tablesorter-js').dataTable({
    "aoColumns": colList
    });
This discussion has been closed.