sClass not working

sClass not working

easymindeasymind Posts: 6Questions: 0Answers: 0
edited March 2009 in Bug reports
Hi, I have experimented with version 1.4.2 of your seemingly great tool.
I am having trouble though getting sClass to work.
As far as I can tell you draw tr objects that are gathered on initialization.
I cannot find the code that handles the sClass variable.
So I have added this to the bottom of the 'process by column' loop in your _fnGatherData function:

/* Add sClass */
if ( oSettings.aoColumns[i].sClass !== null )
{
iLoop = oSettings.aoData.length;
for ( j=0 ; j

Replies

  • easymindeasymind Posts: 6Questions: 0Answers: 0
    edited March 2009
    Adding the next few lines of code to your _fnDrawHead function in the 'visible columns' condition (if ( oSettings.aoColumns[i].bVisible )) fixes the same thing for header cells

    /* Add sClass */
    if ( oSettings.aoColumns[i].sClass !== null )
    {
    nThOriginals[i].className += " "+oSettings.aoColumns[i].sClass;
    }
  • allanallan Posts: 61,697Questions: 1Answers: 10,102 Site admin
    Hi easymind,

    Good catch - thanks for spotting this. It was only working on table rows that were created by DataTables as things stood.

    I've made a fix for this and done a bit of optimisation work in _fnGetherData() now (there was a lot of loops...) so that should see a bit of a speed benefit when using custom column attributes in future. This will be out with 1.4.3, but great that you've posted your fix for 1.4.2 - thanks!

    One thing to note - I hadn't really intended 'sClass' to be applied to the th elements, but only to the td cells. I think I'll leave it to the developer to add a class to th if they want something over and above what is in the DOM.

    Allan
  • easymindeasymind Posts: 6Questions: 0Answers: 0
    Yeah I think I did see some sClass functionality in addData function or something. Ok well, I still think you did a good job developing this thing.
    I don't know if I agree with the header being skipped for classes since one could then optionally not define a th.sClass but only a td.sClass style.
    For me, I generate header cells and table cells from code. So inserting a class on a specific th cell with your js code is better for me. Now I can easily center the whole column without having to mess with my data in my own controller...
    Anyways, thanx for replying and keep it up.
This discussion has been closed.