S
Stefan Mueller
I've a html table which is sortable by clicking on the header of each
column.
Because the sorting sometimes takes a couple of seconds I'd like to
prevent that the user can click the header of a column while the sort
function is running.
Here's my approach:
I do at the end of the sort function
sort_end_time = new Date().getTime();
and at the beginning of the sort function I check how much time has
passed after the sort function finished last time
if ((new Date().getTime() - sort_end_time) > 300) {
In this example you have to wait 300 milliseconds before you can sort
the next column. Therefore if you click on a column before the running
sort function has finished doing its job the value of '(new Date
().getTime() - sort_end_time)' is less than 300 milliseconds and the
clicked column will not get sorted. The problem I have now is that
when the last javascript command 'sort_end_time = new Date().getTime
();' is executed the browser needs some time to redraw (refresh) the
table on the screen. If the table has only a couple of rows then it
takes only some milliseconds but if the table has e.g. 2000 rows it
takes in IE more than 1000 milliseconds. Therefore the result of '(new
Date().getTime() - sort_end_time)' is always greater than 300
milliseconds.
Is there any possibility, any event where I can execute the command
'sort_end_time = new Date().getTime();' just after the browser is
ready again (after the refresh)? In my case the command 'sort_end_time
= new Date().getTime();' (the last command of the sort function) is
executed before the browser starts the redraw (refresh).
Stefan
column.
Because the sorting sometimes takes a couple of seconds I'd like to
prevent that the user can click the header of a column while the sort
function is running.
Here's my approach:
I do at the end of the sort function
sort_end_time = new Date().getTime();
and at the beginning of the sort function I check how much time has
passed after the sort function finished last time
if ((new Date().getTime() - sort_end_time) > 300) {
In this example you have to wait 300 milliseconds before you can sort
the next column. Therefore if you click on a column before the running
sort function has finished doing its job the value of '(new Date
().getTime() - sort_end_time)' is less than 300 milliseconds and the
clicked column will not get sorted. The problem I have now is that
when the last javascript command 'sort_end_time = new Date().getTime
();' is executed the browser needs some time to redraw (refresh) the
table on the screen. If the table has only a couple of rows then it
takes only some milliseconds but if the table has e.g. 2000 rows it
takes in IE more than 1000 milliseconds. Therefore the result of '(new
Date().getTime() - sort_end_time)' is always greater than 300
milliseconds.
Is there any possibility, any event where I can execute the command
'sort_end_time = new Date().getTime();' just after the browser is
ready again (after the refresh)? In my case the command 'sort_end_time
= new Date().getTime();' (the last command of the sort function) is
executed before the browser starts the redraw (refresh).
Stefan