Create a function for customized data tables which can be reused

Create a function for customized data tables which can be reused

kulkarni_ashkulkarni_ash Posts: 35Questions: 8Answers: 0

HI
Does anyone have sample code to create a function for creating a customized data table, for example if i need to have table on 30 screens, i can create one function and use that instead of base $('#example').DataTable()
that way if i change some behavior on one place will change on all the places

Answers

  • scholarlylabsscholarlylabs Posts: 16Questions: 0Answers: 2

    If I understand you correctly, you are looking for a way to reuse your customized datatables code in many places.

    To do this, you can simply change the ID selector '#example' to a class selector like '.mydatatableclass'.

    Thus the initiation code would be: $('.mydatatableclass').DataTable()
    and any table <table class="mydatatableclass">...</table> will be drawn using your customized datatable code.

This discussion has been closed.