alfajango / jquery-dynatable

A more-fun, semantic, alternative to datatables
http://www.dynatable.com
Other
2.77k stars 361 forks source link

cound't add classes to cells #143

Open hamburger123456 opened 10 years ago

hamburger123456 commented 10 years ago

I tried to add classes by using my own cellWriter. But it doesnt works because I cound't write the cell-contend from outside. So I patched the defaultCellWriter. I added this line before return: td += 'class="dynatable'+column.label.toLowerCase()+'"';
It works well, but can you also show how to add a class-name to cells.

drouillard commented 10 years ago

Hi @hamburger123456,

You can specify that the class assigned to the column header be used.

Relevant section of source

https://github.com/alfajango/jquery-dynatable/blob/master/jquery.dynatable.js#L472

Code Pen

http://codepen.io/drouillard/pen/huonc

Need to do 2 things.

  1. Specify you want the class attribute of the headers to be copied to corresponding cells in the table body
    $('#foo_table').dynatable( { table : { copyHeaderClass: true } } );
  1. Specify a class on your column header
<th class='className'>Column Header Value</th>

Does this work?

hamburger123456 commented 10 years ago

it does. your script has still the same version number. is't it 0.3.1a now. And another bug: is in line 1481 //.replace(/^[A-Z]/, function($1){return $1.toLowerCase();});
I have to comment it out because its LowerCase the always data-dynatable-column and you can't get the right td (it will be undefined)

Its not camelCase any more ...

drouillard commented 10 years ago

@hamburger123456 the script I referenced is the existing 0.3.1 I didn't make any updates to prepare this example. The functionality existed.

In general I do need to do release/bump version, but not for this to work.

drouillard commented 10 years ago

@hamburger123456 would you mind filing separate issue for the other issue mention? I don't quite follow and would like to track separately. Thanks.