SELECT filter on top

SELECT filter on top

nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
edited October 2012 in General
Hi,
How would I place the SELECT filters on *top* of the table, rather than below, as seen in the example:
http://datatables.net/release-datatables/examples/api/multi_filter_select.html
Thanks,
Nathan

Replies

  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    If you have a look at that the example you'll see this piece of code:

    [code]
    /* Add a select menu for each TH element in the table footer */
    $("tfoot th").each( function ( i ) {
    this.innerHTML = fnCreateSelect( oTable.fnGetColumnData(i) );
    $('select', this).change( function () {
    oTable.fnFilter( $(this).val(), i );
    } );
    } );
    [/code]

    That's how it is being inserted into the footer. So you'd just need to add another row to the thead and modify the selector to insert into the new header row.

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Thank you for your answer!

    If I have HTML content in my TD, how do I prevent the SELECT OPTION from being populated with this HTML content? I.e. the only content should be the text inside the HTML (text inside a hyperlink)
  • allanallan Posts: 63,531Questions: 1Answers: 10,474 Site admin
    You just need to modify the text that is being used to create the select. For example, in my demo fnCreateSelect function you could replace:

    [code]
    r += ''+aData[i]+'';
    [/code]

    with:

    [code]
    var d = aData[i].replace( /<.*?>/g, "" );
    r += ''+d+'';
    [/code]

    Allan
  • nskwortsownskwortsow Posts: 120Questions: 0Answers: 0
    Merci!
This discussion has been closed.