How to dynamically change column.class?

How to dynamically change column.class?

mbaasmbaas Posts: 51Questions: 18Answers: 0

I've written a "column-visibility"-handler to zebra-strip columns (they get default-styles assigned to them, but as I am using buttons.colwiz user may change the displayed columns and I always want their styling to be correct.
The core of my handler is

if (this.visible()){
 this.nodes().to$().removeClass("oddCol evenCol").addClass(even?"evenCol":"oddCol");

This is working nicely...except that the headers do not change. So, I tried this.header() - but that only returns the HTML of the header, whereas nodes() does return nored that I can work on.
So I am wondering if I am using the different approach altogether???

Basically, the idea is that columns are initialized with a class: "odd" or "even"...and I want to change that (depensing on the visibility of the columns) before redrawing the table (with a different selection of columns). Could I achieve that easier?

This question has an accepted answers - jump to answer


  • allanallan Posts: 48,667Questions: 1Answers: 7,069 Site admin
    Answer ✓

    There is no option to dynamically change it I'm afraid. This is one of the options where you'd need to destroy the table and then create a new one to change the configuration.

    Could you use just CSS to do what you need:

    tr td:nth-child( odd ) {
    tr td:nth-child( even ) {


  • mbaasmbaas Posts: 51Questions: 18Answers: 0

    Thanks, I had not thought about that. Will try to use CSS then.

Sign In or Register to comment.