YUI 3.13数据表加载图像

时间:2013-11-06 19:04:57

标签: yui yui-datatable

我正在尝试创建一个在状态列中显示图像的数据表。我从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>

1 个答案:

答案 0 :(得分:0)

而不是按照我的方式行事,执行以下操作:

{key: "Status", label: "Health Status", formatter:"<img src='{value}' >", allowHTML: true},...

它成功了!

相关问题