javascript jQuery DataTables 为每列添加国家/地区图标
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16122924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
jQuery DataTables add country icons each column
提问by user1480019
I want to add in DataTablesa country iconon each country
column (with jQuery) which is the same as the text that is displayed on that column.
我想在DataTables 中的每列上添加一个国家图标country
(使用 jQuery),它与该列上显示的文本相同。
So when it contains the country US then there is a image before the text that will link to us.png
.
因此,当它包含美国国家/地区时,在将链接到us.png
.
So, from this:
所以,从这个:
to this:
对此:
(Edited in Chrome DevTools)
(在 Chrome DevTools 中编辑)
I think it can be done with aaData
, but I don't know how to use that without replacing the whole column.
我认为可以用 来完成aaData
,但我不知道如何在不替换整个列的情况下使用它。
Somebody has an answer?
有人有答案吗?
采纳答案by Akshay
Use the fnRowCallback
.
使用fnRowCallback
.
Refer this example from the datatables documentation http://datatables.net/release-datatables/examples/advanced_init/row_callback.html
请参阅数据表文档中的此示例http://datatables.net/release-datatables/examples/advanced_init/row_callback.html