【问题标题】:How to set font-weight of a column text to bold based on another column value in Telerik Grid如何根据 Telerik Grid 中的另一列值将列文本的字体粗细设置为粗体
【发布时间】:2015-06-15 08:53:27
【问题描述】:

我有一个 Telerik 网格,根据我的 IsTrue 值是真还是假,我只需要将特定行中名称文本的字体粗细设置为粗体。我尝试了以下方法,但似乎遗漏了一些东西。

columns.Bound(d => d.IsTrue).Width(0).HtmlAttributes(new { id="hdnIsTrue", style = "visibility:hidden;" });
columns.Bound(d => d.Name).ClientTemplate("#<#= hdnIsTrue ? font-weight : bold : font-weight : normal #>#" + "# } #")
                            .Title("Name").Width(200);

【问题讨论】:

    标签: telerik formatting conditional client-templates


    【解决方案1】:

    在帖子的帮助下,我将代码修改为以下内容: Telerik MVC Grid making a Column Red Color based on Other Column Value

    .Columns(columns =>
             {columns.Bound(d => d.IsTrue).Width(0);
              columns.Bound(d => d.Name).Title("Name).Width(200).HtmlAttributes(new { style = "font-weight:normal;" });
    
    }).CellAction(cell => {
                            if (cell.Column.Title == "Name"){
                                  var item = cell.DataItem;
                                  if(item.IsTrue) {
                                      cell.HtmlAttributes["style"] = "font-weight : bold;";
                                  }}}).Render();  
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-20
      • 1970-01-01
      • 2014-04-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多