3

UPDATE:

here is how my html looks like and I have angularjs directive that created for datatables

<table id="vendor" ng-gridview="employee" resource="$employee">
  <thead>
    <tr>
      <th data-name="EmployeeId" data-width="50">Id</th>
      <th data-name="Name" data-width="75">Name</th>
      <th data-name="PhoneNumber" data-width="160">Phone Number</th>
      <th data-name="$options" data-width="160">Options</th>
    </tr>
  </thead>
</table>

How would I display processing message in DataTables whenever it loads the records? I have 20K records and take around 10-15 seconds to load. I am using MVC 5 action method pass the data

I tried using bProcessing as true and sProcessing to give custom progress message but it does not work. How can I achieve that?

/*! DataTables 1.10.2 */

Here is my JQuery Datatables settings:

 settings = {
                        'data': scope[attrs.ngModel] || {},
                        'oLanguage': {
                            'sSearch': 'Search: _INPUT_',
                            'sLengthMenu': attrs.title || 'Display _MENU_ items.',
                            'sInfo': 'Showing _START_ to _END_ of _TOTAL_ items.',
                            "bProcessing": true,
                            "bServerSide": true,
                            "bDeferRender": true,

                            'sLoadingRecords': 'Please wait - loading...',
                            'sProcessing': '<div class="grid-loading"><img src="images/spinner.gif" width="32" align="middle" /> Loading</div>',
                            'sInfoEmpty': 'No entries to show'
                        },
                        'iDisplayLength': 10,
                        "lengthMenu": [5, 10, 20, 30, 50, 100],
                        'columnDefs': []
                    };
4
  • you should really consider to use some pagination anyway Commented Jan 13, 2015 at 14:20
  • yes I'm using pagination but still take that long Commented Jan 13, 2015 at 14:21
  • ah sorry, i was thinking you were displaying 20k records in table at once, my bad. And sorry, couldn't help you regarding your issue Commented Jan 13, 2015 at 14:22
  • your assumuption is correct its displaying 20k recoreds in table at once but i do have pagination and still take 10-15 seconds to load the page Commented Jan 13, 2015 at 14:24

2 Answers 2

3

Assuming your table has <table id="table">

HTML

<div id="message">Loading, please wait</div>
<table id="table></table>

CSS

#table{
    display:none;
}

JS

$('#table').on('init.dt', function () {
    console.log('Table initialisation complete: ' + new Date().getTime());
    $('#table').show();
    $('#message').hide();
})
        .dataTable(settings);
Sign up to request clarification or add additional context in comments.

5 Comments

I have updated my question and if you like to see my angularjs directive I can paste it
just change the js in my example to use id vendor the rest should be the same.
what happened instead
did you get chance to see?
@AbuHamzah I don't know Angular, so I don't think I would be much help there. Is your task to assign different keystrokes to different javascript functions, or is it something beyond that?
1

[Duplicate] You can add in a spinner gif (find one here: http://www.ajaxload.info/) as a div where your table should be and then clear it when the table loads using initComplete.

Something like:

<img id="loading" src="/myspinner.gif">//put this right below `<div class="col-md-12">`

And then call your table like this:

var table = $('#tableId').DataTable( {

            initComplete: function(settings, json) {
                $("#tableId").removeClass("hide");
                $("#tableId").show();
                $("#loading").hide();
            },
     });

Check it here.

Comments

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.