change data table attributes to function

change data table attributes to function

spinxspinx Posts: 3Questions: 1Answers: 0
edited July 2020 in Free community support

hi,
I'm new with datatable, i want to create a global datatable function and use the attribute like 'paging' 'order' 'language' each of them as function declared in a config file which contain the global datatable function to allow me to not repeat many declaration everytime in the project is that possible and how please i'm stuck since 3 days.

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You can create a "DT defaults" script. See here:
    https://datatables.net/manual/options#Setting-defaults

  • spinxspinx Posts: 3Questions: 1Answers: 0

    thank you, but i want that ordering and select to become function cause some table are not the same as other. For example : some need ordering other no some need select checkbox other no and i want to create those select ordering etc.. as function to not write them everytime just call them like this code.
    var table = $('#example').DataTable();
    table.ordering();
    table.select();

  • kthorngrenkthorngren Posts: 21,343Questions: 26Answers: 4,954
    edited July 2020

    Most of the options need to be initialized when initializing Datatables. Some can be set or changed after initialization. Specifically is it looks like you can use select() this way. But there is not a ordering() API. The list of Datatables APIs is here. Each extension has their own list of APIs such as Select APIs are here.

    Kevin

  • spinxspinx Posts: 3Questions: 1Answers: 0

    so basically i can't change those attribute to customized function but i can use the api function only.

This discussion has been closed.