Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/330.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 无法在剑道网格中显示颜色选择器选择的颜色_C#_Kendo Ui_Kendo Asp.net Mvc_Color Picker_Kendo Colorpicker - Fatal编程技术网

C# 无法在剑道网格中显示颜色选择器选择的颜色

C# 无法在剑道网格中显示颜色选择器选择的颜色,c#,kendo-ui,kendo-asp.net-mvc,color-picker,kendo-colorpicker,C#,Kendo Ui,Kendo Asp.net Mvc,Color Picker,Kendo Colorpicker,我有一个带有颜色选择器的网格,当我从调色板中选择颜色时,会显示十六进制颜色代码,而不是状态列中的颜色 这是我的模板编辑器,我称之为QTPStatusEditor: @model string @(Html.Kendo().ColorPickerFor(m=>m) .Name("Status") .Palette(new[] { "rgba(255, 255, 255, 1)", "rgba(0, 204, 0, 1)", "rgba(255, 51, 51

我有一个带有颜色选择器的网格,当我从调色板中选择颜色时,会显示十六进制颜色代码,而不是状态列中的颜色

这是我的模板编辑器,我称之为QTPStatusEditor:

@model string 
@(Html.Kendo().ColorPickerFor(m=>m)
        .Name("Status")
      .Palette(new[] { "rgba(255, 255, 255, 1)", "rgba(0, 204, 0, 1)", "rgba(255, 51, 51, 1)", "rgba(255, 201, 14, 1)" })
      .Columns(4)
      )
这是我的表格:

@(Html.Kendo().Grid<Volvo.Qarma.MVCWebUIComponent.Models.Views.ProposedQToolViewModel>()
              .Name("QTPGridItems_#=Id#")
               .ToolBar(toolbar => toolbar.Template(@<text>
                <div class="toolbar">
                   <input type="button" id="SaveProposedQTools" class="icon save k-grid-save-changes" value="@ScreeningResource.Screening_TreatmentPlan_SaveProposedQTools" />
                </div>
            </text>))
              .Columns(columns =>
              {
                  columns.Bound(o => o.RefQTool.Name).Title("Pro-active actions");
                  columns.Bound(o => o.Responsable).Title("Responsible");
                  columns.Bound(o => o.QtoolLeader).Title("Qtool Leader");
                  columns.Bound(o => o.Location.LongName).EditorTemplateName("LocationListEditor").Title("Location");

                  columns.Bound(o => o.Status).EditorTemplateName("QTPStatusEditor").Title("Status");

                  columns.Bound(o => o.PlannedStartDate).EditorTemplateName("PlannedStartDateEditor").Title("Planned start date").Format("{0:dd/MM/yyyy}");
                  columns.Bound(o => o.PlannedEndDate).EditorTemplateName("PlannedEndDateEditor").Title("Planned End date").Format("{0:dd/MM/yyyy}");
                  columns.Bound(o => o.LastUpdateDate).EditorTemplateName("LastUpdateDateEditor").Title("Last Update Date").Format("{0:dd/MM/yyyy}");
                  columns.Bound(o => o.LinkToDocument).Title("Link To Document");
                  columns.Bound(o => o.Comment).Title("Comment");
              })
              .DataSource(dataSource => dataSource
                  .Ajax()
                  .Batch(true)
                  .ServerOperation(false)
                  .PageSize(10)
                  .Read(read => read.Action("QtpGridSelectedQtools", "QTP", new { itemId = "#=Id#" })
                   .Data("function() { return getCommodityID('QTPGridItems_#=Id#');}"))
                   .Create(create => create.Action("Create_TreatmentPlan", "Screening", new { itemId = "#=Id#" }))
                   .Update(update => update.Action("Update_TreatmentPlan", "Screening", new { itemId = "#=Id#" }))
                  .Model(model =>
                  {
                      model.Id(p => p.Id);
                      model.Field(p => p.Id).Editable(false);
                      model.Field(p => p.RefQTool.Name).Editable(false);
                      model.Field(p => p.Responsable).Editable(true);
                      model.Field(p => p.QtoolLeader).Editable(true);
                      model.Field(p => p.Location).Editable(true).DefaultValue(ViewData["defaultLocation"] as LocationsViewModel);
                      model.Field(p => p.PlannedStartDate).Editable(true);
                      model.Field(p => p.PlannedEndDate).Editable(true);
                      model.Field(p => p.LastUpdateDate).Editable(true);

                      model.Field(p => p.Status);

                  })
              )

              .Selectable()
              .Pageable()
              .Sortable()
              .Editable(editable => editable.Mode(GridEditMode.InCell))

              .ToClientTemplate()

        )
@(Html.Kendo().Grid())
.Name(“QTPGridItems#=Id#”)
.ToolBar(ToolBar=>ToolBar.Template(@
))
.列(列=>
{
columns.Bound(o=>o.RefQTool.Name).Title(“主动操作”);
columns.Bound(o=>o.Responsible).Title(“Responsible”);
columns.Bound(o=>o.QtoolLeader).Title(“QtoolLeader”);
columns.Bound(o=>o.Location.LongName).EditorTemplateName(“LocationListEditor”).Title(“位置”);
columns.Bound(o=>o.Status).EditorTemplateName(“QTPStatusEditor”).Title(“Status”);
columns.Bound(o=>o.PlannedStartDate).EditorTemplateName(“PlannedStartDateEditor”).Title(“计划开始日期”).Format(“{0:dd/MM/yyyyy}”);
columns.Bound(o=>o.PlannedEndDate).EditorTemplateName(“PlannedEndDateEditor”).Title(“计划结束日期”).Format(“{0:dd/MM/yyyyy}”);
columns.Bound(o=>o.LastUpdateDate).EditorTemplateName(“LastUpdateDateEditor”).Title(“上次更新日期”).Format(“{0:dd/MM/yyyyy}”);
columns.Bound(o=>o.LinkToDocument).Title(“链接到文档”);
columns.Bound(o=>o.Comment).Title(“Comment”);
})
.DataSource(DataSource=>DataSource
.Ajax()
.Batch(真)
.ServerOperation(错误)
.页面大小(10)
.Read(Read=>Read.Action(“QtpGridSelectedQtools”,“QTP”,new{itemId=“#=Id#”})
.Data(“函数(){return getCommodityID('QTPGridItems#=Id#')}”))
.Create(Create=>Create.Action(“Create_TreatmentPlan”,“Screening”,new{itemId=“#=Id#”}))
.Update(Update=>Update.Action(“更新治疗计划”、“筛选”,新的{itemId=“#=Id#”}))
.Model(Model=>
{
model.Id(p=>p.Id);
model.Field(p=>p.Id).可编辑(false);
model.Field(p=>p.RefQTool.Name).可编辑(false);
model.Field(p=>p.responsible).可编辑(true);
model.Field(p=>p.QtoolLeader).可编辑(true);
model.Field(p=>p.Location).Editable(true).DefaultValue(ViewData[“defaultLocation”]作为LocationsViewModel);
model.Field(p=>p.PlannedStartDate).可编辑(true);
model.Field(p=>p.PlannedEndDate).可编辑(true);
字段(p=>p.LastUpdateDate).Editable(true);
model.Field(p=>p.Status);
})
)
.可选()
.Pageable()
.Sortable()
.Editable(Editable=>Editable.Mode(GridEditMode.InCell))
.ToClient模板()
)
我在一些示例中看到需要添加.ClientTemplate(“
);致:

columns.Bound(o=>o.Status).EditorTemplateName(“QTPStatusEditor”).Title(“Status”).ClientTemplate(“”);
但当我这样做时,我得到一个javascript错误:uncaughtreferenceerror:Status未定义 您也可以在附件中看到。线不再显示在网格中

非常感谢您的帮助


关于,这里是剑道管理员的解决方案:

实际上,在当前场景中,使用客户机模板是正确的方法。由于当前网格位于客户机模板本身中,因此应转义作为模板一部分的哈希符号

.ClientTemplate("<div style='background-color: \\#=Status\\#;padding:10px;'> </div>");
.ClientTemplate(“”);

您是否尝试过
?您好@chiapa,谢谢您的回答,事实上,当我尝试您提供的解决方案时,没有Javascript错误,显示了行,但无法显示所选的颜色。因此,当我在浏览器中检查元素时,背景颜色未定义。有什么想法吗?谢谢是的,那是因为
状态
没有值。确保您的模型中填充了有效的颜色值嗨,我已经在telerik论坛上发布了kendo管理员的解决方案:.ClientTemplate(“”);很高兴你找到了答案!
.ClientTemplate("<div style='background-color: \\#=Status\\#;padding:10px;'> </div>");