WTM Grid 表格支持图片展示

发布于 2020-04-16 13:02:35

DataTableTagHelper.cs

代码第 838 行修改为

private string getTemplate(string field)
{
    return $@"function(d){{
        var sty = '';var bg = '';var did = '{field}_'+d.LAY_INDEX;if(d.{field}__bgcolor != undefined) bg = ""<script>$('#""+did+""').closest('td').css('background-color','""+d.{field}__bgcolor+""');</s""+""cript>""; if(d.{field}__forecolor != undefined) sty = 'color:'+d.{field}__forecolor+';'; if(/^https?:[^:<>""]*\/([^:<>""]*)\.((png!thumbnail)|(png)|(jpg)|(webp)|(jpeg)|(gif))$/.test(d.{field})) return '<div style=""'+sty+'"" id=""'+did+'"">'+'<img src=""'+d.{field}.replace(/\""/g,""'"")+'"" style=""max-width: 60px;max-height: 30px;""></img>'+bg+'</div>'; return '<div style=""'+sty+'"" id=""'+did+'"">'+d.{field}.replace(/\""/g,""'"")+bg+'</div>';
    }}
    ";
}

基本逻辑是判断数据为图片链接用img加载下!

0 条评论

发布
问题