jQuery 数据表 - 绑定数据时访问行 ID

jQuery Datatables - Access Row ID when binding data

我正在使用 jQuery 数据表,我的一些行在列选项数组中定义了 select 个框:

ddlOptions = '<option value="val">Text</option>'

"columns": [
    { data: "DateOfService", defaultContent: "" },
    {"defaultContent": "<select id=\"TimeIn1\" class=\"timeDDL\">" + ddlOptions + "</select>"},
    {"defaultContent": "<select id=\"TimeOut1\" class=\"timeDDL\">" + ddlOptions + "</select>"}
]

当我创建 select 框时,所有 ID 都将相同,因此我需要为它们提供所有单独的 ID。我在想我可以只使用我的数据集中的 RowId 属性,但我该怎么做呢?

经过更多挖掘,我找到了这个页面:http://datatables.net/reference/option/columns.render

上面有下面的例子:

$('#example').dataTable( {
  "columnDefs": [ {
    "targets": 0,
    "data": "download_link",
    "render": function ( data, type, full, meta ) {
      return '<a href="'+data+'">Download</a>';
    }
  } ]
});

full参数包含了我所有的Row数据,这正是我所需要的。希望这对其他人有帮助...