首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >如何在datatable中显示图像?

如何在datatable中显示图像?
EN

Stack Overflow用户
提问于 2009-08-04 08:50:09
回答 1查看 3.6K关注 0票数 1

如何在datatable的单元格中显示图像而不是布尔值?datatable与数据源相关联。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2009-08-05 22:37:21

您可以使用自定义的formatter函数将任何超文本标记语言放入您的单元格中。列定义可能如下所示:

代码语言:javascript
代码运行次数:0
运行
复制
var myColumnSet = [
    {
        key: 'active_employee',
        label: 'Active',
        formatter: function(el, oRecord, oColumn, oData) {
            // el is the HTMLElement of the current cell
            // oRecord gives you access to other fields from the
            //    DataSource, e.g.: oRecord.getData('full_name')
            // oData is the value of the current field (active_employee)

            if (oData) {
                el.innerHTML = '<img src="/images/active.png">';
            } else {
                el.innerHTML = '<img src="/images/not-active.png">';
            }
        }
    },
    // other Columns....
];

另请参阅Custom Cell Formatting example

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1226372

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档