简体   繁体   中英

Can I use pace instead of data-table's processing?

I'd like to use PACE for Datatable 's ajax requests. So , I disabled the datatable's processing as processing : false . And then what do I need to work PACE 's processing bar for showing every Datatable 's ajax requests ?

It sounds like it should just work by default for AJAX requests, if you're wanting it to apply for sorting/processing events you might need something like the following:

Adapted from https://datatables.net/reference/event/processing You'll probably want to trigger PACE on the datatable processing event by the sounds of things:

$('#dataTable')
    .on( 'processing.dt', function ( e, settings, processing ) {
        if(processing){
            Pace.start();
        } else {
            Pace.stop();
        }
    })
.dataTable();

Well if you want to show the PACE for every ajax request in your application then you can specify it like below

Adding the pace options before loading it.

    <script>
        window.paceOptions = {
            ajax: {
                trackMethods: ['GET', 'POST', 'PUT', 'DELETE', 'REMOVE']
            }
        };

    </script>
    <script src="../js/progressBar/pace.min.js"></script>

This will show up your PACE progress bar for every ajax request to your server.

Is simple use this form:

$('#dataTable').on('processing.dt', function(e, settings, processing) {
    if (processing) {
      Pace.stop();
      Pace.bar.render();
    } else {
      Pace.stop();
    }
  }).DataTable();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM