Possible to edit how fnServerData is rendered? Insert classes and skip cells?

Possible to edit how fnServerData is rendered? Insert classes and skip cells?

ginjaninjaginjaninja Posts: 5Questions: 0Answers: 0
edited June 2013 in DataTables 1.9
Sorry if this is redundant. It's hard to explain what I'm looking for, and even harder to Google. I am using dataTables to display an interactive list of users that looks like this: http://www.flickr.com/photos/97024286@N07/8960402297/

As you can see there are icon buttons mixed in with the user data. I wanted to change the table so it's being populated via fnServerData, (right now it's built on page load then turned into a dataTable). I can't tell if there's a way to interrupt the output from fnServerData and add classes to empty cells, and add some data from fnServerData as attributes of a cell, not the text. Is that possible? The code below is an example of a couple cells. Hope this makes sense. Thanks!

[code]



{first name from database}
[/code]

Replies

  • ginjaninjaginjaninja Posts: 5Questions: 0Answers: 0
    Nevermind! I found this, which is exactly what I was looking for:
    http://www.datatables.net/release-datatables/examples/server_side/row_details.html
  • ginjaninjaginjaninja Posts: 5Questions: 0Answers: 0
    aoColumns takes care of the cell classes, but the other part I'm still not sure about. My ajax returns id, name, and other details. I don't want to show the id, but I do want to set the first cell's id to the id returned for that row. Is that possible?
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    Yes - you can use the fnCreatedCell callback to manipulate the cell.

    Allan
  • ginjaninjaginjaninja Posts: 5Questions: 0Answers: 0
    edited June 2013
    Perfect, thanks! One more question, can I skip a cell or do I need to put an empty val in my JSON? I have 8 columns, but only 4 values for each row.
  • allanallan Posts: 63,133Questions: 1Answers: 10,399 Site admin
    You can use sDefaultContent to assign default content for a cell that has no information from the data source.

    Allan
  • ginjaninjaginjaninja Posts: 5Questions: 0Answers: 0
    You rock!
This discussion has been closed.