How do I re-index search?

How do I re-index search?

flowerchild22flowerchild22 Posts: 2Questions: 0Answers: 0
edited May 2013 in General
I periodically change the text content of my table dynamically after it has been created (not using any methods from datatables.js). Search will still display rows based on the old data. I have tried calling fnDraw without success. How can I trigger a re-indexing of table data for search?

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    Currently, the only way is to use the DataTables API. v1.10 is going to include an invalidate() method (indeed, I've just implemented it this week), which will have it re-read data from the original source, but its still an API method that you need to call to tell DataTables that something has happened.

    Allan
  • flowerchild22flowerchild22 Posts: 2Questions: 0Answers: 0
    edited June 2013
    Looking forward to v1.10! For now I'm re-creating the entire table when I need to re-index using
    [code]
    function refreshTable(oTable, originalOptions) {
    oTable.fnDestroy();
    oTable.dataTable(originalOptions);
    }
    [/code]
    Not efficient, but seems to work fine (couldn't get bDestroy working, seemed to always mess up the layout). Thanks for a fantastic library Allan!
This discussion has been closed.