A few issues

A few issues

theshelftheshelf Posts: 1Questions: 0Answers: 0
edited October 2009 in General
Hi - I just started using DataTables instead of a few plugins. It's awesome.

Just having a couple little issues...

My table is dynamically generated and a number of columns are dependent on permissions - therefore it's a little hard to tell it which column to sort by what. Is it possible to make EVERY column strip all html before sorting by the default (date, or number etc)? There are hundreds of rows so adding another element (with a hidden title field) to every column of every row wouldn't be ideal.

I'm also using the fixed header plugin - it works well on my first table, but I'm using jQuery UI tabs - the tables that are initially hidden in tabs don't work with this plugin no matter how I initialise them (by class, id, table).

That's it for now :)

Any help would be appreciated.

Cheers

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Hi theshelf,

    Sorry for the long delay in replying to you about this.

    1. To strip all html from the rows before sorting, you could just set the sType for each column to 'html'. However, this won't help with the numeric columns since DataTables will treat the 'html type as a string. What makes this a bit complicated is that you mention that each column could be either a number or a string. For the numeric columns, you can use the Numbers with HTML sorting plugin: http://datatables.net/plug-ins/sorting#numbers_html , but what I think you will need to do is write two type detection plug-ins, one for the numbers, and one for HTML based strings. Add the numbers type detection first, and then is that doesn't match have your next plug-in return 'html' always. To add to the start of the type detection array you can use the array unshift() method.

    2. Fixed headers require that the browser has already calculated the offsetWidth of the various elements in the table, and this won't be the case if you have the table initially hidden. This is an optimisation by the browser to speed things up a bit during first render. So what you need to do is call the fnUpdate() API function for the FixedHeader object that is created when you initialise it, when your user changes tables - since at this point the browser will calculate the dimensions of the table.

    Hope this helps,
    Allan
This discussion has been closed.