Font resizing

Font resizing

qdsolutionsqdsolutions Posts: 2Questions: 0Answers: 0
edited April 2014 in General
I'm offering a web app that contains a large number of datatable reports all using the same code to keep everything simplified and central. With different screen sizes, column lengths etc. you get tables of varying widths and at the moment the container will contain the table to the page width and they can scroll horizontally to see the rest. The built in column sizing works really well but I'd like to implement some additional smart font sizing to try and get a best fit. For example if I run a report that has the last column cut in half because it is slightly too large, I'd prefer to drop the font by 1px and get it to fit

Without too much effort I think I could add some additional processing to fnDrawCallback to see whether the table is outside the bounds of the page and loop through some font sizes to try and get a better fit. But since fnDrawCallback is called so often I'm not sure this is the most efficient way possible and perhaps trying to hook into the existing column sizing methods may give better results to try and limit the amount of processing required. Is there anybody who can offer an elegant solution for this type of issue? Is there anything already out there that does this?

Replies

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    DataTables 1.10 adds a `column-sizing` event which might be of use to you: http://next.datatables.net/reference/event/column-sizing ?

    Another option is to use the `initComplete` ( fnInitComplete in 1.9-) callback which is run only once during the table's life time if that is what you want.

    Having said that, the draw callback might not be so bad - you just need to be a little careful that it can't call itself. Otherwise, infinite loop...! A little flag to say "this is a resize draw" would do.

    Allan
  • qdsolutionsqdsolutions Posts: 2Questions: 0Answers: 0
    Thanks Allan, will have a look.
This discussion has been closed.