Is there any way to change options after initializing dataTable?

Is there any way to change options after initializing dataTable?

mickypcmickypc Posts: 4Questions: 1Answers: 0

i want to change the ajax options after initializing a dataTable,my version is 1.10.7
any idea is appreciated.

This question has an accepted answers - jump to answer

Answers

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16

    A bit more information here is very much welcome. What options would you like to change? Do you wish to reload the datatable? Do you simply want to redraw the datatable?

    Are you trying to perform a search? Do you use controls outside of the datatable that you want to initiate the reload?

    Too many questions, please provide us with more insight.

    Hope this helps,

  • mickypcmickypc Posts: 4Questions: 1Answers: 0

    Thanks a lot. sorry for my vague question.
    i am going to perform a search in the server-side schema.i just want to change my ajax.data params to include my search keyword and then reload the dataTable.

  • mickypcmickypc Posts: 4Questions: 1Answers: 0

    Before:
    "ajax": {
    "url": "man_stucr_act.jsp",
    "data": {
    "act": 1
    },
    "dataSrc": "stucrs"
    }

    After:
    "ajax": {
    "url": "man_stucr_act.jsp",
    "data": {
    "act": 1,
    "keyword": "search something"
    },
    "dataSrc": "stucrs"
    }

  • allanallan Posts: 63,361Questions: 1Answers: 10,448 Site admin
    Answer ✓

    Generally no, there is no way to change the options after initialisation. However, in the case of ajax.data - just use it as a function. The function will be evaluated at the point every Ajax request is made, so you can easily modify the parameter based on whatever criterion you need at that point in time.

    Allan

  • mickypcmickypc Posts: 4Questions: 1Answers: 0

    Thanks. a pretty nice solution!!!

This discussion has been closed.