Setting defaults

Setting defaults

PWXCaptCrunchPWXCaptCrunch Posts: 3Questions: 1Answers: 0

I am trying to set default options for all initializations of data tables across the whole application. I have seen examples using this:

$.extend(true, $.fn.dataTable.defaults, {
        "searching": false,
        "ordering": false
    });

My question is where do I put that JS code?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948

    Here is the docs for this:
    https://datatables.net/manual/options#Setting-defaults

    Looks like you place that code before you initialize your Datatables.

    Kevin

  • PWXCaptCrunchPWXCaptCrunch Posts: 3Questions: 1Answers: 0

    If you have to do it before you initialize your tables it isn't really the global solution I hoped it would be. At that rate I might as well just put the options I want in each initialization. I thought this would create a config file or something so that anywhere I initialized a table in my app would have those options by default.

  • kthorngrenkthorngren Posts: 21,310Questions: 26Answers: 4,948
    Answer ✓

    This option is for a page that has multiple Datatables and default settings are desired. I don't believe it can be used as a global setting tor multiple pages but I might be wrong.

    Kevin

  • PWXCaptCrunchPWXCaptCrunch Posts: 3Questions: 1Answers: 0

    That's what I was afraid of thanks for responding though. @kthorngren

This discussion has been closed.