如何根据 Telerik Grid 中的另一个列值将列文本的字体粗细设置为粗体
How to set font-weight of a column text to bold based on another column value in Telerik Grid
我有一个 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);
在 post 的帮助下,我将代码修改为以下内容:
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();
我有一个 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);
在 post 的帮助下,我将代码修改为以下内容: 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();