id or class method ?

id or class method ?

Philip HarveyPhilip Harvey Posts: 23Questions: 0Answers: 0
edited April 2009 in General
I have a table set up with the 'id' method and all works well (except sorting, see my other post :-)) but as I understand it I can only have one table on a page. I have tried the 'class' method but that does not seem to respect the column width statements. I have used the "bAutoWidth": false statement.

Am I missing something ?

Regards
Phil

Replies

  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin
    Hi Phil,

    You certainly can have multiple tables initialised from a single class - have a look at the example here: http://datatables.net/examples/example_multiple_tables.html . If this doesn't work for you, perhaps you can provide a link to your example.

    Thanks,
    Allan
  • Philip HarveyPhilip Harvey Posts: 23Questions: 0Answers: 0
    Hi Allan, thanks for your comments. I can get the multiple tables on a page to work, my problem is more about control of the column widths. If I use a definition such as The table still shows as full width.

    Also if I specify a column width in a table using the 'id' method and then change to the 'class' method the columns are a lot wider... I think I will convert all my tables to the 'class' method and resize the columns as it looks and works well ... but it would be nice to have narrow tables when there is only a couple of columns to show.

    Thanks for your patience
    Phil
  • allanallan Posts: 54,897Questions: 1Answers: 8,605 Site admin
    Hi Phil,

    I see what you mean - thanks for clearing that up. One thing to note is that if you are using my demo CSS then you might well have:

    [code]
    table.display {
    margin: 0 auto;
    width: 100%;
    clear: both;
    }
    [/code]

    This would override the width="50%" in your HTML. it might be best to remove this CSS statement if you want to use the HTML defined statements. Firebug is ideal for figuring out where styles are coming from.

    Allan
This discussion has been closed.