添加指向数据表的链接以获取更多信息

我有这个代码清单,我想添加一个指向datatables的链接,我收到一个错误:DataTables warning(table id =’example’):从第0行的数据源请求未知参数’3’,当我点击好吧,它没有加载我添加的链接,这是我的代码

 $(document).ready(function() { var oTable = $('#example').dataTable( { "bProcessing": true, "sAjaxSource": "", "aoColumns": [ { "mData": "bank_id" }, { "mData": "bank_name" }, { "mData": "absolute_amount" }, { "fnRowCallback": function( nRow, aData, iDisplayIndex ) { $('td:eq(3)', nRow).html('operations/display/' + aData[0] + '">' + aData[0] + ''); return nRow; } }, ] } ); } );  
Client ID Client Name Absolute Limit History

编辑我的意思是说mRender更适合在服务器端实现上使用FnRowCallback来从数据创建URL

这是一个使用您的代码的示例,添加它并删除FnRowCallback

  { "mData": null , //its null here because history column will contain the mRender "mRender" : function ( data, type, full ) { return ''+full[0]+'';} }, 

文档: http : //www.datatables.net/release-datatables/examples/advanced_init/column_render.html

您需要在aoColumns为history属性输入一个条目,该条目应该可以解决您所看到的错误。 数据表期望表中每列的值,即使您计划以编程方式设置该值。 我还没有找到办法解决这个问题。

此外,您的fnRowCallback不应该是aoColumns的一部分。 fnRowCallback应该是datatables配置对象的一部分(即aoColumns的对等aoColumns )。

你的配置看起来像这样:

 { "bProcessing": true, "sAjaxSource": "", "aoColumns": [ { "mData": "bank_id" }, { "mData": "bank_name" }, { "mData": "absolute_amount" }, { "mData": "history" } //need an entry here for history ], "fnRowCallback": function(nRow, aData, iDisplayIndex) {...} } 

您的数据将如下所示:

 [{ "bank_id":1, "bank_name": "Fred's Bank", "absolute_amount": 1000, "history": "" }, ... ]