Font resizing
Font resizing
qdsolutions
Posts: 2Questions: 0Answers: 0
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?
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?
This discussion has been closed.
Replies
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