首页 文章

对剑道网格列使用Template和ClientTemplate

提问于
浏览
0

我在ASP.NET MVC中使用了一个kendo网格,我想将某些颜色规则应用于某些列的单元格 . 为此,我尝试过HtmlAttributes(使用类似乎是最简单的方法)和ClientTemplate,但两者都没有用 . 此外,我根据ViewModel中的变量创建了许多列 .

我即将声明一个布尔选项卡,意味着每个列必须是可见的(因此看起来似乎是静态的) . 我不能动态地使用columns.Bound(),但是我能够在for循环中动态地添加columns.Template()的列 .

Html.Kendo().Grid<ViewModelPilotageRetroPlanningOpeDetail>() //Bind the grid to ViewBag.Products
        .Name("pilotageRetroPlanningListeOpesDivabc")
        .BindTo(Model.ListeOpes)
        .Columns(columns =>
        {
             columns.Bound(ope => ope.NbTachesRetard).Title("Nb tâches en retard").Template(@<text> @if (item.NbTachesRetard != 0)
             {
                 <span class="retards"> @item.NbTachesRetard </span>
             }
             else
             {
                 <span class="pasDeRetards"> @item.NbTachesRetard </span>
             }
             </text>);


            for (int i = 0; i < Model.NombreJalonsUtilises; i++)
            {
            var index = i;
            columns.Template(@<text> @item.ListeStatutJalon.ElementAt(index).ToString() </text>).Title("J" + (i + 1).ToString()).Width(25);
             }
        }

它工作并显示所需的列enter image description here

现在我需要显示图像而不是数字,我需要使用ClientTemplate将单元格与img标签相关联

我的问题是: Is it possible to use both Template and ClientTemplate to add a class based on the value given by @item.ListeStatutJalon.ElementAt(index) ? 因为当我添加ClientTemplate时,模板的值不会出现在单元格中 .

1 回答

相关问题