What is the difference between columns.adjust() vs columns.adjust().draw() ?
What is the difference between columns.adjust() vs columns.adjust().draw() ?

When I am changing a dropdown value within a DataTable then it brings the user to the top of the Table (titles ) .
After analyzing the code I found that
" table.columns.adjust().draw(false) "
is being used on change of the dropdown to adjust column width of entire table to correctly accommodate new custom column response .
When I changed the code from " table.columns.adjust().draw(false) " to " table.columns.adjust()" it is not bringing the user to the top of the Table which resolves my issue . But I want to know the diff between
" table.columns.adjust().draw(false) " & " table.columns.adjust()" . Thanks in advance .
Answers
Hi @ashwinrajagopal ,
Calling
columns.adjust()
won't redraw the display - so the change in widths won't happen until the next draw (such as when the ordering is changed or a different page selected). Thedraw()
does the refresh.Cheers,
Colin
Hi @colin ,
Thank you very much for the information . But when I am changing a value of dropdown in the table , it fires an event which does some data fetch so to adjust the newly populated data I am using columns.adjust().draw() but it will scroll up to the table header making the user confusing as the page is being scrolled up rather than staying in the specific row . How can we fix this issue ? Please suggest any solution if you could .
Hi @ashwinrajagopal ,
Try
draw('page')
, that may help. If not, we're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.Cheers,
Colin
@colin Thank you Colin . But still I am facing the issue .
Actual issue is when I am trying to call adjust().draw(false) or adjust.draw('page') on an drop down change event which is placed towards the bottom of the DataTable
( where the scroll is down ) , will take the user to the title of the DataTable (scrolling up ) . I tried creating a test case as per the link
live.datatables.net/bidarezi/2/edit
you provided but it is not getting reproduced ) .
Hi @ashwinrajagopal ,
Thanks for the demo, but as you say, it's not reproducing the issue. Without seeing it, it's hard to diagnose and make any further suggestions.
Cheers,
Colin
Hi @colin
I have found one thread in stack overflow related to this but the solutions provided are not working for me . Any suggestion from your side , would be a great help . Thank you
https://stackoverflow.com/questions/27663743/how-to-maintain-jquery-datatables-scroll-position-after-draw
Hi @ashwinrajagopal ,
As I said in my last two comments, the best way to progress this is to provide a test case - without it, we're shooting in the dark.
Cheers,
Colin