Changing the inner scroll after initialization?
Changing the inner scroll after initialization?
First off, great plug-in - I'll get to buying you a beer one of these days.
I have a table with 20-30 columns and the user can select which columns they wish to view. This obviously involves some horizontal scrolling and everything works great up to this point. However, if they're only interested in say, five columns, there's no point to having an inner scroll of 400%. Therefore, I would like to change the inner scroll amount based on how many columns they wish to view. It'd be nice to not reinitialize as there could be several tables on the page that would need to change at once. I tried something like this:
[code]
var blah = $("#table").dataTable();
blah.fnSettings().oScroll.sXInner = "300%";
blah.fnAdjustColumnSizing();
[/code]
Oddly enough this will change the outer width to 300% and changing oScroll.sX doesn't seem to have any effect (not that I want to change it.) This is in version 1.8.2.
I have a table with 20-30 columns and the user can select which columns they wish to view. This obviously involves some horizontal scrolling and everything works great up to this point. However, if they're only interested in say, five columns, there's no point to having an inner scroll of 400%. Therefore, I would like to change the inner scroll amount based on how many columns they wish to view. It'd be nice to not reinitialize as there could be several tables on the page that would need to change at once. I tried something like this:
[code]
var blah = $("#table").dataTable();
blah.fnSettings().oScroll.sXInner = "300%";
blah.fnAdjustColumnSizing();
[/code]
Oddly enough this will change the outer width to 300% and changing oScroll.sX doesn't seem to have any effect (not that I want to change it.) This is in version 1.8.2.
This discussion has been closed.
Replies
I'd suggest not setting the inner scroll size at all actually - DataTables should resize as required based on the number of columns. Certain things such as white-space:nowrap; can help enforce that scrolling (otherwise it will try to wrap lines to make them fit) but generally I would recommend not using inner scrolling.
Having said that, your approach I think is more or less correct, but try calling fnDraw(false) rather than fnAdjustColumnSizing - I wouldn't have executed the column sizing to do what you describe, but it wasn't exactly that would happen, so there could be something funny going on there...
Allan