How to add rows and attributes to the datatable?

How to add rows and attributes to the datatable?

san0820san0820 Posts: 9Questions: 1Answers: 0
edited October 2013 in DataTables 1.8
Hi,


I am trying to add data to a datatable as rows which are coming from a JSON returning java controller.

While adding rows there must be id from the JSON to every in the table
some thing like this


json.tdjson.tdjson.tdjson.td

since i am having an event on clicking that tr,

I am totally a beginner to datatables and littlebit to jquery as well

Please help me,
Thanks,
Sankar.

Replies

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    You can use the `DT_RowId` option to add an ID to each row as shown in this example: http://datatables.net/release-datatables/examples/server_side/ids.html

    Allan
  • san0820san0820 Posts: 9Questions: 1Answers: 0
    Hi Allan,

    Thank u very much for your reply with an answer,
    After my observation through the link given, what understood is, the server side people must add an "DT_RowId": id details, right?
    if so, can u please tell me is there any other possibility to assign the id to every row iteratively based on the json data?

    Thanks,
    Sankar.
  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Another method is to use the fnCreatedRow callback and assign the I'd in your callback function.

    Allan
  • san0820san0820 Posts: 9Questions: 1Answers: 0
    Hi Allan,
    Thanks again,
    If you dont mind , can u please provide me an example on that.


    Thanks,
    Sankar.
  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin
    Just click on the link... There is an example of how to use the callback in the documentation...
  • san0820san0820 Posts: 9Questions: 1Answers: 0
    edited October 2013
    thank u very much Allan and so nice to chat with u.
    Will try to keep in touch with u to get all my issues fixed.

    Thanks,
    Sankar.
This discussion has been closed.