Domen Dolar - 2025-09-11

Datatable basic
1. Official documentation site: https://datatables.net/
2. Default values of DataTable are stored in JavaScript variable _rasd_dataTableProperties

       const _rasd_dataTableProperties = 
        {
          "responsive": false,
          "bJQueryUI": true,
          "aaSorting": [],
          "oLanguage": {
            "sSearch": "Search on table",
            "sZeroRecords": "No data available in table"
        },
        "bPaginate": false,
        "pageLength": 10,                  
        "bLengthChange": true,
        "bFilter": true,
        "bSort": true,
        "aaSorting": [],            
        "bInfo": false,
        "bAutoWidth": false //have to be false because otherwise radio buttons on first line are not checked - known bug in 1.9.4
        };

3.How to set or edit values with javascript. There is BLOCK2, bock where DataTable will be changed. You can us all properties of DataTable object. Not only these in default properties.

$(function() {
  // Create new json data
   var newDT1 = JSON.parse(JSON.stringify(_rasd_dataTableProperties));
   // Modify values
   newDT1.sSearch = 'Search:'; 
   // Destroy
   newDT1.destroy = true;
   //  remove class 'rasdTableN' from block (in this case 'BLOK2_TABLE') 
   $("#BLOK2_TABLE").removeClass( "rasdTableN" ); 
   // Apply modified settings to block 
   var xTable1 = $("#BLOK2_TABLE").DataTable(newDT1);
});

Thanks to Pavel who prepare this topic.

 

Last edit: Domen Dolar 2025-09-11