Open In App

DataTables processing Option

Last Updated : 31 May, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

DataTables is jQuery plugin that can be used for adding interactive and advanced controls to HTML tables for the webpage. This also allows the data in the table to be searched, sorted, and filtered according to the needs of the user. The DataTable also exposes a powerful API that can be further used to modify how the data is displayed.

The processing option is used to specify whether the processing indicator is enabled or not. This indicator is shown when the DataTable is busy doing some operation that would take some time. This is useful for tables that have a huge amount of data and take a lot of time to perform any operation. This indicator would be able to notify the user that an operation is going on and has not got stuck. A true value displays the indicator and a false value removes it.

Syntax:

{ processing: value }

Option Value: This option has a single value as mentioned above and described below:

  • value: This is a boolean value that specifies the processing indicator is enabled or not. The default value is false.

The below example illustrates the use of this option.

Example 1: This example enables the processing indicator that can be seen while sorting the columns.

HTML




<html>
  
<head>
    <!-- jQuery -->
    <script type="text/javascript" 
    </script>
  
    <!-- DataTables CSS -->
    <link rel="stylesheet" href=
  
    <!-- DataTables JS -->
    <script src=
    </script>
</head>
  
<body>
    <h1 style="color: green;">
        GeeksForGeeks
    </h1>
    <h3>DataTables processing Option</h3>
  
    <!-- HTML table with student data -->
    <table id="tableID" class="display" 
        style="width: 100%;">
    </table>
  
    <script>
  
        // Initialize a huge dataset to 
        // see the effects of processing
        let dataset = [];
        for (let i = 0; i < 250000; i++) {
            let newArr =
                [i, "Random Data: " + i, Math.random()];
            dataset.push(newArr);
        }
  
        // Initialize the DataTable
        $(document).ready(function () {
            $('#tableID').DataTable({
  
                // Add the data created above
                data: dataset,
                columns: [
                    { title: "Index" },
                    { title: "String Index" },
                    { title: "Random" },
                ],
  
                // Enable the processing indicator
                // of the DataTable
                processing: true,
            });
        });
    </script>
</body>
  
</html>


Output:

Example 2: This example disables the processing indicator.

HTML




<html>
  
<head>
    <!-- jQuery -->
    <script type="text/javascript" 
    </script>
  
    <!-- DataTables CSS -->
    <link rel="stylesheet" href=
  
    <!-- DataTables JS -->
    <script src=
    </script>
</head>
  
<body>
    <h1 style="color: green;">GeeksForGeeks</h1>
    <h3>DataTables processing Option</h3>
  
    <!-- HTML table with student data -->
    <table id="tableID" class="display"
        style="width: 100%;">
    </table>
  
    <script>
  
        // Initialize a huge dataset to 
        // see the effects of processing
        let dataset = [];
        for (let i = 0; i < 250000; i++) {
            let newArr =
                [i, "Random Data: " + i, Math.random()];
            dataset.push(newArr);
        }
  
        // Initialize the DataTable
        $(document).ready(function () {
            $('#tableID').DataTable({
  
                // Add the data created above
                data: dataset,
                columns: [
                    { title: "Index" },
                    { title: "String Index" },
                    { title: "Random" },
                ],
  
                // Disable the processing indicator
                // of the DataTable
                processing: false,
            });
        });
    </script>
</body>
  
</html>


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads