add code in script

add code in script

Alex2019Alex2019 Posts: 62Questions: 9Answers: 0
edited July 2019 in Free community support

Hello,
how to add and where this in the script,
I get an error if I enter it, :/

order": [[ 1, "asc" ]]

thank you

<script>
    $(document).ready( function () {
  var table = $('#personal').DataTable({
    "createdRow": function( row, data, dataIndex ) {
             if ( data[5] == "Dvd" ) {        
         $(row).addClass('grey');
         }
         if ( data[5] == "Vhs" ) {        
         $(row).addClass('yellow');
     
       }
      

    }
  });
} );
    </script>

Replies

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765
    edited July 2019

    Anywhere in the Datatables init, like this:

      var table = $('#personal').DataTable({
        "order": [[ 1, "asc" ]],
        "createdRow": function( row, data, dataIndex ) {
                 if ( data[5] == "Dvd" ) {       
             $(row).addClass('grey');
             }
             if ( data[5] == "Vhs" ) {       
             $(row).addClass('yellow');
          
           }
           
     
        }
      });
    

    Note the comma at the end of the line to separate options.

    Kevin

  • Alex2019Alex2019 Posts: 62Questions: 9Answers: 0

    mystery solved, sorry I'm new for Datatables, :D
    thank you kthorngren

  • Alex2019Alex2019 Posts: 62Questions: 9Answers: 0

    This not work :/

    "language": {"localhost/Movie/": "italian.lang"},

    italian.lang is located localhost in the Movie folder

  • kthorngrenkthorngren Posts: 20,275Questions: 26Answers: 4,765

    I think you are looking for the language.url option. The examples should help.

    Kevin

  • Alex2019Alex2019 Posts: 62Questions: 9Answers: 0

    strange, not work :/

     "language": {"url": "/Movie/italian.lang"},
    
    

    link localhost

    http://localhost/Movie/italian.lang
    
This discussion has been closed.