JQuery DataTables link item
Posted
by
rogcg
on Stack Overflow
See other posts from Stack Overflow
or by rogcg
Published on 2012-04-12T23:24:49Z
Indexed on
2012/04/12
23:29 UTC
Read the original article
Hit count: 207
I'm trying to link the items from a specific column, but each one will be linked for a different id
from the json string. Unfortunately I can't find a way to do this using the API (I know there is a lot of ways to do that without using the API ), but I'm looking for a way to link a item from a column (each one with a link for a specific id
).
So here is my code, I use getJSON
to get the JSON from the server, and I load the data from this JSON to the table like this:
$.getJSON("/method/from/server/", function(data)
{
var total = 0;
$("#table_body").empty();
var oTable = $('#mytable').dataTable(
{
"sPaginationType" : "full_numbers",
"aaSorting": [[ 0, "asc" ]]
});
oTable.fnClearTable();
$.each(data, function(i, item)
{
oTable.fnAddData(
[
item.contact_name,
item.contact_email
]
);
});
});
What I want to do, is for each row, link the contact_name
to its id
, which is also in the JSON, and can be accessed inside this $.each
loop by using item.contact_id
.
Is there a way to do this using DataTables API, if yes, could you explain me and provide a good resource that will help me with this?
Thanks.
© Stack Overflow or respective owner