简体   繁体   English

我可以使用速度而不是数据表的处理吗?

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

I'd like to use PACE for Datatable 's ajax requests.我想将PACE用于Datatable的 ajax 请求。 So , I disabled the datatable's processing as processing : false .因此,我将数据表的处理禁用为processing : false And then what do I need to work PACE 's processing bar for showing every Datatable 's ajax requests ?然后我需要什么来工作PACE的处理栏来显示每个Datatable的 ajax 请求?

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: 听起来默认情况下,它应该仅适用于AJAX请求,如果您希望将其应用于排序/处理事件,则可能需要以下内容:

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: 改编自https://datatables.net/reference/event/processing您可能想通过事物的声音在datatable处理事件上触发PACE:

$('#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 好吧,如果您想为应用程序中的每个ajax请求显示PACE ,则可以如下指定

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. 这将显示对服务器的每个ajax请求的PACE进度栏。

Is simple use this form:使用这种形式很简单:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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