Datatables HTML5 Reference?

Datatables HTML5 Reference?

VorkoVorko Posts: 12Questions: 2Answers: 0
edited February 2022 in DataTables 1.10

I have been trying to migrate all my Javascript initialization into HTML5 properties. Sadly there is very limited reference to do so. Just this:
DataTables example - HTML5 data-* attributes - cell data
DataTables example - HTML5 data-* attributes - table options

Would someone have a real reference? I am indeed trying to use (among other things) the equivalent of

columnDefs: [
        { targets: [3, 4], className: 'text-center'}
      ],
language:{
  url: 'myi18npath'
},

"stripeClasses": [],

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,443Questions: 26Answers: 4,974
    edited February 2022 Answer ✓

    The HTML5 data attributes used for the init options is here. Take note of the need to use double quotes for strings and how to handle camel case. sounds like you need a valid JSON string. Here is an example of the language.url and columnDefs options:
    http://live.datatables.net/zanosuyo/1/edit

    Kevin

  • VorkoVorko Posts: 12Questions: 2Answers: 0

    Thank you, indeed it works

    Do you know how to use also stripeClasses?

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    You can use that like this:

          <table data-stripe-classes='["first", "second"]' id="example">
    

    Please see example here,

    Colin

  • VorkoVorko Posts: 12Questions: 2Answers: 0

    Thanks for the prompt answer :)

    Last question, how can you implement server side processing?

    "processing": true,
    "serverSide": true,
    ajax: {
    url: "customurl",
    type: "post",
    dataType: "json",
    headers: {
    'X-CSRF-Token': csrf
    }
    },

  • allanallan Posts: 63,678Questions: 1Answers: 10,498 Site admin
    Answer ✓
    <table data-processing='true' data-serverSide='true' data-ajax='{url: ...
    

    You'll need a stringified JSON for your ajax object.

    Allan

  • VorkoVorko Posts: 12Questions: 2Answers: 0

    Thank you very much to both of you, I was able to make it work.

Sign In or Register to comment.