我正在尝试创建一个在状态列中显示图像的数据表。我遵循了stackoverflow中的一些示例,但它不起作用。有谁知道如何让图像加载到列中?下面的代码有效,但似乎 fomatter 函数没有做任何事情。
<script src ="http://yui.yahooapis.com/3.13.0/build/yui/yui-min.js"></script>
<script>
(function() {
YUI().use("datatable-sort", function(Y) {
var cols = [
{key: "Status", label: "Health Status",
formatter: function(el, oRecord, oColumn, oData) {
if (oData){
el.innerHTML = '<img src="info.png">';
}
},
sortable: true},
{key: "Company", label: "Issue", sortable: true},
{key: "Phone", label: "Contact"},
{key: "Contact", label: "Name", sortable: true}
],
data = [
{Status: "123", Company: "Company Bee", Phone: "415-555-1234", Contact: "Sally Spencer"},
{Status: "123", Company: "Acme Company", Phone: "650-555-4444", Contact: "John Jones"},
{Status: "123", Company: "Industrial Industries", Phone: "408-555-5678", Contact: "Robin Smith"}
],
table = new Y.DataTable({
columns: cols,
data: data,
summary: "Contacts list",
caption: ""
}).render("#sort");
});
})();
</script>