jquery datatable - How to use render function get data from another column

匿名 (未验证) 提交于 2019-12-03 09:52:54

问题:

I have add button in each row ,but I want to check if info column data is N/A, then not shown the button, I have try to set render as below in my code ,but it's not work

{     "targets": -1,     "data": null,     "render": function ( data, type, row )      {         if (row.info != 'N/A') {         return "<button href='" + row.index() + "' class='btn btn-info'>View</button>"         } else { return "" }      }     }                     }

Any help/advice is greatly appreciated. Willing to post any more information if it will help.

回答1:

Working Link Here

"render": function(data, type, full, meta ) {     if (full.info != 'N/A') {         return "<button href='" + row.index() + "' class='btn btn-info'>View</button>"     } else {         return ""     } }


回答2:

Render is documented here: https://datatables.net/reference/option/columns.render

You aren't using the same name of arguments documented there, but in the examples, you would use full to access all of the available columns and data is the current column. I'm not sure where you got field from. So data from info would be accessed at full.info.

An example being:

"render": function ( data, type, full, meta ) {   return '<a href="'+data+'">' + full.info + '</a>'; }


标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!