Hi, is it possible to get the width of each column? I'm using a datatable inside a dialog-ui and i would like to know the widths after a resize or a change in visible columns using colvis.
EDIT: heh, I must've been writing while Mike said he figured it out. ;-) Ah well, I'll leave my solution here anyhow for future readers; might be useful to SOMEONE out there!
Not familiar with dialog-ui OR colvis option, but in general you should be able to get the width of the columns based on a DOM selector.
With jQuery, something like:
[code]
$('#example th')
[/code]
Will give you an array of the th elements in the table with the id 'example'. If you know the position within the array, you can access it directly like this:
[code]
$('#example th').eq(2).width();
[/code]
Which will give you the width (not outerWidth, mind you) of element 2 (ie the third element) in the array. You could iterate through instead of accessing directly, if that's what you need to do.
Hope that helps and that I haven't totally missed the boat on what you're looking to do!
EDIT: could also hook into the header row callback (fnHeaderCallback?)
Replies
Not familiar with dialog-ui OR colvis option, but in general you should be able to get the width of the columns based on a DOM selector.
With jQuery, something like:
[code]
$('#example th')
[/code]
Will give you an array of the th elements in the table with the id 'example'. If you know the position within the array, you can access it directly like this:
[code]
$('#example th').eq(2).width();
[/code]
Which will give you the width (not outerWidth, mind you) of element 2 (ie the third element) in the array. You could iterate through instead of accessing directly, if that's what you need to do.
Hope that helps and that I haven't totally missed the boat on what you're looking to do!
EDIT: could also hook into the header row callback (fnHeaderCallback?)