Documentation for DataTables() constructor

Documentation for DataTables() constructor

creidiekicreidieki Posts: 7Questions: 3Answers: 0

Hi, according to https://datatables.net/reference/type/DataTables.Api one of the ways to create a DataTables API object is through the $( selector ).DataTable(); call. But that call isn't listed in the list below, or described anywhere on the page. Where is it documented? For example, what are the parameters of that call? (It's used with parameters on https://datatables.net/examples/basic_init/filter_only.html ).

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954

    When $( selector ).DataTable(); is used the first time it will initialize the table element(s) matching the selector. Once initialized, the call to $( selector ).DataTable(); returns an instance of the API for that table. Subsequent uses of $( selector ).DataTable(); will retrieve an API instance for that table.

    The initialization options are documented here under Reference > Options. The API is documented here under Reference > API.

    Does this answer your questions?

    Kevin

  • creidiekicreidieki Posts: 7Questions: 3Answers: 0

    But what are the arguments to the DataTable() method? Is that what you mean by an "initialization option"?

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395
    edited March 2021

    Hi, according to https://datatables.net/reference/type/DataTables.Api one of the ways to create a DataTables API object is through the $( selector ).DataTable(); call. But that call isn't listed in the list below, or described anywhere on the page.

    The documentation you linked to has this among other examples and explanations:

    $( selector ).DataTable(); example
    var table = $('#myTable').DataTable();

    @kthorngren has shown you where to find the initialization options which may accompany the initial call. I'm not sure what else you want.

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

    But what are the arguments to the DataTable() method? Is that what you mean by an "initialization option"?

    As Kevin said, all of the options are listed under Reference->Options - and anything passed in to that constructor are what we call the initialisation options For example, this here shows how you can render columns and use Ajax to get the data,

    Colin

  • creidiekicreidieki Posts: 7Questions: 3Answers: 0

    So the DataTable() function takes zero or one parameters. If there's one parameter it should be an object. Any attributes of that object are referred to as "options" in the documentation, and will be interpreted according to the Options section of the documentation?

    That's all I was asking about. It seems like that should be stated in the documentation.

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited March 2021 Answer ✓

    Its documented in the Installation Manual Initializing Datatables section:

    If you want to customise your DataTable, this can be done by specifying configuration parameters in an object passed to the DataTable() function. For information on how to use these configuration parameter, please refer to the options manual page.

    There is a lot of documentation and its not always easy to find everything :smile: After awhile you will get a feel for where to look.

    Kevin

  • creidiekicreidieki Posts: 7Questions: 3Answers: 0

    Okay, but that kind of information should be in the Reference section too, not just the Manual.

This discussion has been closed.