Update table settings after initialisation

Update table settings after initialisation

sbarnettsbarnett Posts: 23Questions: 5Answers: 0

Is it possible to update table settings after the table has been initialised?

I'm trying to write a library which can be used by various users which sets up the table in the most basic way and I would like them to be able to update the table settings once I've init'ed the table for them.

For instance, I'll initialise the table to use server side processing with a url of "." but I would like them to be able to change the url to something else and/or add a data function to be called before the server processing is done using ajax.data.

I'd also like them to be able to update the orderable or searchable settings in the same way.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,352Questions: 1Answers: 10,443 Site admin

    You can update some - any that have an API method. If you want to be able to change them all, or any that don't have an API method, you'd need to destroy the existing table and then create a new one with the new settings.

    In the case of the Ajax URL, that can be changed using ajax.url().

    Allan

  • sbarnettsbarnett Posts: 23Questions: 5Answers: 0

    Ah, funnily enough I've just got to the stage where I can work around setting the other items I need to set - by passing in arrays of integers for the things like orderable etc.

    But the one I'm really having problems with is changing the data that's sent with ajax setting.

    It doesn't look like that one's got an API method - so would I need to recreate the table from scratch to set that then?

  • allanallan Posts: 63,352Questions: 1Answers: 10,443 Site admin

    Do you mean the columns.data property? If so, then yes, you would need to destroy and recreate the table to modify that. There is no API to change that after initialisation.

    Allan

  • sbarnettsbarnett Posts: 23Questions: 5Answers: 0

    In actual fact, I meant the ajax.data property but I guess the same thing applies?

  • allanallan Posts: 63,352Questions: 1Answers: 10,443 Site admin
    Answer ✓

    Yup, 'fraid so. I have been thinking of ways to make that configurable via the API and hope to introduce that in future, but at the moment you'd need to re-init the table.

    Another option might be to have ajax.data call a function and you could modify what that function does. Adds another layer, but it would save re-initing the table.

    Allan

  • sbarnettsbarnett Posts: 23Questions: 5Answers: 0

    Excellent - thanks for your help as always!

This discussion has been closed.