Add Class to Datatable Elements?

Add Class to Datatable Elements?

TomCTomC Posts: 43Questions: 0Answers: 0
edited August 2009 in General
I want to add a class to the pagination buttons so that I can use jQuery UI themes. I can see a way to make it look like that by copying the attributes I want to datatable.css but how do you add or change class names on datatable generated elements? It seems from the documentation that sClass only adds classes to table elements not the datatable controls.

Replies

  • allanallan Posts: 61,722Questions: 1Answers: 10,108 Site admin
    Hi Tom,

    You are correct in that DataTables doesn't currently provide a method for you to select which classes are applied to the dynamically created elements (it's on the to-do list!) - but there are ways to do what you are looking for:

    1. After DataTables as initialised, just added the classes then by querying the DOM and using $.addClass(). This should happen so fast that the user would never see the flicker.

    2. Use a plug-in pagination function ( http://datatables.net/development/pagination ) and assign your classes directly in the paging setup function.

    Regards,
    Allan
  • TomCTomC Posts: 43Questions: 0Answers: 0
    Yeah i figured I could use addClass() I just wanted to make sure there wasn't a datatables way to do it before i added post-load js. Last time I tried that I was busy using jQuery to wrap all sorts of divs around the datatable before I found the sDOM function. lol
This discussion has been closed.