Best way to add hidden values to cell?

Best way to add hidden values to cell?

soroushhakamisoroushhakami Posts: 10Questions: 0Answers: 0
edited September 2011 in General
Scenario: I am sending function_name and function_id via AJAX. The function_name is displayed in a column. When a function_name-cell is clicked, I want to to fire off a javascript with the function_id value. What is the best way to achieve this?

A thought I had was to add it to aoColumns as seen below, and make it invisible somehow. But this seems overly complicated, and it would still technically be two different cells. Is there some way to send some hidden parameter data to each cell perhaps?

Big thanks in advance

[code]
"aoColumns": [
{ "mDataProp": "function_name" }
{ "mDataProp": "function_id" }
]
[/code]

Replies

  • soroushhakamisoroushhakami Posts: 10Questions: 0Answers: 0
    Perhaps a solution can be made with JQuerys way of storing arbitrary data?
    http://api.jquery.com/data/
  • soroushhakamisoroushhakami Posts: 10Questions: 0Answers: 0
    Solved this. For how, see http://stackoverflow.com/questions/7316579/best-way-to-add-hidden-data-to-cell-in-datatables-net/7318834#7318834
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The answer in StackOverflow is bob on :-). You can put any properties you want in the object you give to DataTables for the data, and then mDataProp lets you pull some out as you need them. In combination with fnGetData this can be quite powerful.

    Allan
  • soroushhakamisoroushhakami Posts: 10Questions: 0Answers: 0
    Thanks alot for confirming my solution Allan!
This discussion has been closed.