在 Alloy UI 数据 Table 中显示 link

Display link in Alloy UI Data Table

我想在 alloy ui 数据 table 中添加超链接。下面是我的代码。

<head>
    <link href="http://cdn.alloyui.com/3.0.1/aui-css/css/bootstrap.min.css" rel="stylesheet"></link>
    <script src="http://cdn.alloyui.com/3.0.1/aui/aui-min.js"></script>
    <script>
        YUI().use(
          'aui-datatable',
          function(Y) {
            var columns = ['name', 'address', 'city', 'state','edit'];

            var data = [
              {address: '1236 Some Street', city: 'San Francisco', name: 'John A. Smith', state: 'CA', edit:'<a href="www.google.com">Google</a>'},
              {address: '3271 Another Ave', city: 'New York', name: 'Joan B. Jones', state: 'NY', edit:'<a href="www.google.com">Google</a>'},
              {address: '9996 Random Road', city: 'Los Angeles', name: 'Bob C. Uncle', state: 'CA', edit:'<a href="www.google.com">Google</a>'},
              {address: '1623 Some Street', city: 'San Francisco', name: 'John D. Smith', state: 'CA', edit:'<a href="www.google.com">Google</a>'},
              {address: '9899 Random Road', city: 'Los Angeles', name: 'Bob F. Uncle', state: 'CA', edit:'<a href="www.google.com">Google</a>'}
            ];

            new Y.DataTable.Base(
              {
                columnset: columns,
                recordset: data
              }
            ).render('#myDataTable');
          }
        );
    </script>
</head>
<body>
    <div id="myDataTable"></div>
</body>

在显示期间,它显示 html 作为字符串。我怎样才能将它显示为超链接?

我认为我们无法在 JSON 中添加标记,但是否有机会完成我的工作。任何帮助将不胜感激...!!

我认为您可以调整列定义以适应 link。

比如说,如果您想在 edit 列下的值上使用 link,则必须将其定义为:

var columns = [
    'name', 
    'address', 
    'city', 
    'state',
    {
        key: 'edit',
        allowHTML: true // Must be set or the html will be escaped
    }
];

不过我还没有测试过这个。您可以找到有关 Datatable Formatters here.

的更多信息