No access to page, and tables don't have thead - Assume first is thead mode?

No access to page, and tables don't have thead - Assume first is thead mode?

gishnetworkgishnetwork Posts: 7Questions: 0Answers: 0
edited August 2012 in General
In instances where one does not have access to the table code, but can reach in with jQuery, why is there no "Assume the first set is actually the THEAD"?

It seems so simple. Like

AssumeFirst: yes

No?

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    No - DataTables has always required a fully marked up table with a THEAD and TBODY: http://datatables.net/usage/#prerequisites . This will not change.

    Having said that, it is very easy to use a couple of lines of jQuery to manipulate the DOM:

    [code]
    // Create a THEAD and move the first row into it
    $('#example').append( 'thead' );
    $('#example thead').append( $('#example tbody tr:eq(0)') );

    // ... initialise DataTables
    [/code]

    (assumes you have a tbody of course :-) ).

    Allan
  • gishnetworkgishnetwork Posts: 7Questions: 0Answers: 0
    I basically did something like this, except I needed to retain the contents of the original "header" as it has i18n data in there already.

    There are a lot of non DT ways to accomplish things that DT can do. It's seems arbitrary for DT to have on it's list of prerequisites something that DT could handle if it wanted to, chopping off a prerequisite and/or workaround. I am not saying one should not code in a thead/th. Just saying it seems odd that there are cases where one would need to use jQuery to accomplish something explicitly to allow DT to even work.

    I really do think there are a lot of older large industry vendors who have tech that was coded 98 - 2005 that in most cases does not have a thead. I should say think - I know, because I am dealing with one that has a crapton of clients. These are vendors that move like molasses, but are not in a sexy industry that is attracting younger developers, so the UX/UI, and proper coding is left behind.

    Anyway, food for thought.
This discussion has been closed.