hidden columns when javascript disabled

hidden columns when javascript disabled

carteriiicarteriii Posts: 25Questions: 1Answers: 0
edited October 2010 in General
I'm looking for advice for how to handle hidden columns when javascript is disabled.

When javascript is disabled, I'd still like my static html table to appear properly. This means that columns which are hidden by DataTables should not be visible. I can't simply remove the columns of data from the html entirely or else DataTables will generate errors when javascript is enabled.

Do I need to add a style="display:none" to each and element (yes, I know I can also use a css class) for all columns to be hidden? Is there a preferred or more efficient way to hide a column in the static representation of the table such that DataTables will still work properly when javascript is enabled?

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    What is in the hidden column? Can it be added dynamically by Javascript (progressive enhancement). For example if it's data you could loop over the table inserting the elements from an array before initialising DataTables.

    Allan
  • carteriiicarteriii Posts: 25Questions: 1Answers: 0
    Ah, I see what you are thinking. I had not thought of that because I am using server-side processing and an ajax call to get the data which nicely returns everything at once. I didn't want to make two calls to get my data, but as long as I run my javascript to create the additional columns *before* the creation/definition of the dataTable, all the dataTable configuration will stay the same. I think I can just create empty columns via javascript and then let DataTables do its normal thing.

    For what it's worth, I did try adding the style="displaye:none;" to all and elements and that did work properly, but I like & agree with the progressive enhancement approach. Thank you.
This discussion has been closed.