Reading data from AJAX created DataTable

Reading data from AJAX created DataTable

rickitanrickitan Posts: 1Questions: 0Answers: 0
edited September 2011 in General
Hey guys I need some help reading information from a Datatable that I creat using the ajax functions. This is what I'm trying to do:

After the table is created and displayed on the browser, I let the user select any row and detect this row with the fnGetSelected function, after that I need to read the information on that row So I can deploy a colorbox with the information on the row he clicked.

Is there a function to read the information? And the problem is since I'm creating it through ajax the code isn't on the page source!
Thanks in advanced!

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    When DataTables is rendering (ie. when you initialize or call fnDraw on a table), it has access to the data that is retrieved with AJAX. You can bind your event to the row using the fnRowCallback. This is exactly what I've done in the past to add a "more details"callout when hovering on a row.

    Everything you need to get started is here:

    http://datatables.net/release-datatables/examples/api/row_details.html

    Except of course you would modify it so that a) the row itself has the click bound to it; ditch the parts adding a new column and widget; b) show the details in a colorbox instead of in a slide-down details box.

    Greg
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Side note: if you don't need information from your hidden data rows (ie. the aData), you can always "fake it" by binding a function that grabs the contents of each cell in a clicked row to be re-displayed in a Colorbox. Once the AJAX is finished, the values will indeed be on the page and you can grab them with .text().

    But I think doing it in the initialization is a better and more flexible way.
  • helbohelbo Posts: 2Questions: 0Answers: 0
    I have the same problem as rickitan. I am new here and I am sorry, but I didnot understand your explanation GregP. Can you kindly explain it more deeply and concretly? Thank you.
This discussion has been closed.