添加链接到数据表以获取更多信息 [英] Adding a link to datatables for more information
问题描述
DataTables warning(table id ='example'):请求的未知参数'3'从数据源对于第0行,当我点击确定,它不加载我添加的链接,这是我的代码
< script type =text / javascriptcharset =utf-8>
$(document).ready(function(){
var oTable = $('#example')。dataTable({
bProcessing:true,
sAjaxSource :<?php echo base_url('operations / dataDisplayBanks /');?>,
aoColumns:[
{mData:bank_id},
{mData:bank_name},
{mData:absolute_amount},
{
fnRowCallback:function(nRow,aData,iDisplayIndex){
$('td:eq(3)',nRow).html('<?php echo base_url()?> operations / display /'+ aData [0] +'>'+
aData [0] +'< / a>');
返回nRow;
}
},
]
});
});
< / script>
< div id =demo>
< table cellpadding =0cellspacing =0 border =0class =displayid =example>
< thead>
< tr>
< th>客户端ID< / th>
< th>客户端名称< / th>
< th绝对限制< / th>
< th>历史< / th>
< / tr>
< / thead>
< tbody>
< / tbody>
< tfoot>
< / table>
< / div>
编辑我的意思是说mRender优先使用FnRowCallback在服务器端实现从数据创建url
这里是一个使用代码的例子,添加它并删除FnRowCallback
{mData:null,//这里为null,因为历史列将包含mRender
mRender:function(data,type,full){
return'< a href =<?php echo base_url();?> operations / display /'+ full [0] +'>'+ full [0] +' a>';}
},
文档: http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html
I have this code listing, i would like to add a link to datatables, I am getting an error: DataTables warning (table id = 'example'): Requested unknown parameter '3' from the data source for row 0, When i click ok, it does not load the link i have added, Here is my code
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "<?php echo base_url('operations/dataDisplayBanks/'); ?>",
"aoColumns": [
{ "mData": "bank_id" },
{ "mData": "bank_name" },
{ "mData": "absolute_amount" },
{
"fnRowCallback": function( nRow, aData, iDisplayIndex ) {
$('td:eq(3)', nRow).html('<?php echo base_url() ?>operations/display/' + aData[0] + '">' +
aData[0] + '</a>');
return nRow;
}
},
]
} );
} );
</script>
<div id="demo">
<table cellpadding="0" cellspacing="0" border="0" class="display" id="example">
<thead>
<tr>
<th>Client ID</th>
<th>Client Name</th>
<th>Absolute Limit</th>
<th>History</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
</table>
</div>
EDIT i meant to say mRender is preferred for use over FnRowCallback on server-side implementations to create urls from data
here is an example using your code, add it and remove the FnRowCallback
{ "mData": null , //its null here because history column will contain the mRender
"mRender" : function ( data, type, full ) {
return '<a href="<?php echo base_url(); ?>operations/display/'+full[0]+'">'+full[0]+'</a>';}
},
Docs: http://www.datatables.net/release-datatables/examples/advanced_init/column_render.html
这篇关于添加链接到数据表以获取更多信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!