bProcessing API?

bProcessing API?

scullytrscullytr Posts: 12Questions: 0Answers: 0
edited September 2012 in General
Hello,

I was wondering if there was some sort of api for the "Processing..." message. Perhaps a way to pass custom messages to that div and fire it off for user-feedback.

I can, of course, hack something together myself, but I wanted to know if there was anything more clean and built-in. No sense in reinventing things. :-)

Thank you!

-Tim.

Replies

  • allanallan Posts: 63,535Questions: 1Answers: 10,475 Site admin
    You can use the sProcessing language option to change what is shown, but there is no current API to change the message on-the-fly (a plug-in could be created if you need it). There is a plug-in to control the show / hide of the indicator: http://datatables.net/plug-ins/api#fnProcessingIndicator .

    Allan
  • scullytrscullytr Posts: 12Questions: 0Answers: 0
    Thank you Allan. That helps a lot.

    From what I read in other posts, there isn't a way to change the value of sProcessing after dataTable init, so what I did (after using the above method) is directly changed the innerHTML of the div, displayed the custom message, hid the message, and changed it back to "Processing...", like so:

    Plugin:
    [code]
    $.fn.dataTableExt.oApi.fnProcessingIndicator = function ( oSettings, onoff )
    {
    if( typeof(onoff) == 'undefined' )
    {
    onoff=true;
    }
    this.oApi._fnProcessingDisplay( oSettings, onoff );
    };
    [/code]

    Custom message method:
    [code]
    function notify(msg){
    var msgSpot = $('.dataTables_processing');

    // Default value if none is specified
    msg = typeof(msg) == 'undefined' ? 'Processing...' : msg;

    // Replace the text in the nofication area with the specified text, and make it visible
    $(msgSpot).html(msg);
    oTable.fnProcessingIndicator();

    // After 2 seconds, hide the notice, and put it back the way we found it
    setTimeout(function(){
    oTable.fnProcessingIndicator(false);
    $(msgSpot).html('Processing...');
    }, 2000);
    }
    [/code]
This discussion has been closed.