0

I'm doing the server side sorting in datatable plugin. Data takes 4-5 seconds to load, in the mean time if the user clicks on other headers it will again trigger the AJAX call.

How can I restrict the user when the servers side data is still in processing state? Is there any initial function where I can check custom Flag status & stop the sortable till processing is done?

1
  • Hi there, did you get anywhere with this? I posted a tested and exact solution to your problem but we've got no feedback about what you did and what happened and whether you problem was solved. Can you let us know please? Commented Nov 4, 2010 at 12:08

4 Answers 4

2

When you first get the request, disable the button. Then enable the button in a callback function which is triggered when the server finishes. That's how you'd do it, but if you want code, then give code.

Sign up to request clarification or add additional context in comments.

7 Comments

I believe he was asking how that can be achieved, not what could he possibly try and do. "Please help me on how to restrict the user when the servers side data is still in processing state. Is there any initial function where i can check custom Flag status & stop the sortable till processing is done.??"
I told him how it can be achieved. Difficult to provide an implementation when the only environment details we're given is "jquery".
hi, here teh problem is that how to disable the datatables click on header which triggers sort? even i can set teh flag & implement the same but here the problem is how to disable the table header click temporarily.
Also, please look at the datatables server side link which i have provided.
@EMMERICH he seemed to already know that is how to achieve what he wanted, just didn't know how to actually do it. I offered a solution that will work for pretty much any code he is using but got no up votes :( @janardhan "here the problem is how to disable the table header click temporarily" That's what hiding the element does. When it is hidden it cannot be clicked on and the click event will not fire. Is the problem how to select that element? Or do you want a way that it will still show but not be clickable?
|
1

Just a quick tip:

  • set async: false
  • disable sorting buttons
  • enable them upon successful request

1 Comment

async: false won't help, if the user can't click on the button (disabled) it will make no difference (except possibly slow/hang page responses). If the user can click on the button, the request will still be stacked up for being sent off when current one completes.
0

If memory serves me correctly jquery has 3 functions like ajaxStart(), ajaxError() and ajaxComplete().

Simply disable the whole grid/just the grid header when ajaxStart and enable it again when either ajaxError (where you can do some error handling) or ajaxComplete.

Comments

0

There are a variety of ways to do this, the easiest will depend on your code.

$(document).ajaxSend( function(){
   $('controls_selector').hide();
}).ajaxComplete( function(){
   $('controls_selector').show();
});

This will do it, however this will disable them for the duration of any ajax event on your page. The documentation describes how you can use the callback function's parameters to determine the nature of the ajax call and selectively show/hide those elements.

This way you can avoid digging in and playing with the code for the plugin.

Update

The sticking point seems to be that you don't want to hide the elements, you want a way to temporarily disable the event handlers and since they are buried in datatables you don't want to modify them. I would do the following:

var tableheadclone = $('#mytableid thead>tr>th').clone(true);

then write that clone somewhere else and hide it (or keep it in a global js variable). You can then use

$('#mytableid thead>tr>th').unbind('click');

to remove the event handler.

You can re-instate the event handler using the replaceWith() jQuery function.

2 Comments

please refer my above comments. Is there a way we can bind the click to whole parent, so that child clicks are not detected by sorting plugin. i see some limitations in the capture mode (opp to bubbling)
My updated answer gives a complete solution to your problem. If you can't work out how to implement it we need more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.