refresh javascript sourced data

refresh javascript sourced data

distrirecargasdistrirecargas Posts: 1Questions: 1Answers: 0

Hi, If a table is initialized with Javascript sourced data and want to refresh table with new Javascript sourced data ? How we do it ? in data-tables version 1.10

Answers

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Well since its a local javascript source, you cant just change it and update the table, that would work if you used ajax (which I would prefer, then you can just use ajax.load()

    Since you're using just local JS, you would have to clear the whole table via clear(), then add all the rows via rows.add(), then of course you'd have to draw() it after that.

    http://live.datatables.net/vunuqipe/1/edit?js,output

    This does require you to keep the columns the same though, if you plan on changing the columns, then you should just specify the destroy option when you first initialize the DT instance, then re-initialize the entire table the 2nd time

    Goodluck

This discussion has been closed.