Jedit and Json

Jedit and Json

eijnokeijnok Posts: 2Questions: 0Answers: 0
edited November 2009 in General
Hi i'm using a setup where i'm getting all my data using Ajax calls and Json return the data to be inserted in the table.
Im now looking to be able to use jedit also in the table, and my problem is that i can send the variables value that is the value in the td, but jedit also send the td:s id as an identifier, but as im using ajax and json to get tha data from my DB i would need to also send a id variable with the json return, to be inserted in the table as the corresponding td id. Is there an easy way to do this?

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi eijnok,

    What you need to do, as you have noted, is to get an ID which can be used by the server-side process to update the target row. So to do this you need to instruct jEditable where to find this value. There are a number of discussions in this forum about exactly this issue, but given that there is this thread and one just two or there below it about this topic I think it's probably best if I update my example to show how this might be done with jEditable, which I have now done: http://datatables.net/examples/api/editable.html

    Hope this helps,
    Allan
  • eijnokeijnok Posts: 2Questions: 0Answers: 0
    Yeah the example you showed does add a value of row_id to the post, but my problem is that i have no values to send in the post. When i get the data from the server and echo out the json for datatables to read, i would need to also add an id to every entry there, corresponding to the database id and column.
    When i now get the Json result, and insert the data into Datatables, it autogenerates the table for me, and i would like that i culd send a specific id for every td.
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi eijnok,

    In that case I see a couple of options:

    1. Modify the return to have a unique ID in the row (a hidden column possibly) - this combined with the column number will give you the location required.
    2. Have a hidden id in each cell - which is also returned with the json
    3. Modify the table after DataTables has rendered it with the IDs required.

    There are other ways to do it as well - basically all you need to do is get the unique ID, and how you do it will depend on your setup and preferences.

    Regards,
    Allan
This discussion has been closed.