// set up the datatablse
var table = $('#example').DataTable();
// list of descriptions for each person
var desc = {
"Ashton Cox": "Ashton is a baller",
"Cedric Kelly": "Died in the last harry potter movie",
"Garrett Winters": "this guy is cold af"
};
// loop each row
$('#example tbody').find("tr").each(function(){
// get the name which matches the keys in our
// descriptions, in this case it's in the first col
var name = $(this).find("td").eq(0).text();
if(!name.length) return;
if(undefined === desc[name]) return;
table.row($(this)).child(desc[name]).show();
});
演示:https://jsfiddle.net/j767gs8t/1
看一看https://datatables.net/examples/api/row_details.html –
謝謝,我確實看過這個......我仍然對這是如何工作的有點困惑......很想找到一篇關於它的更詳細的文章。 – davemackey