【问题标题】:Bind EditorTemplate file to grid combobox in Kendo UI MVC将 EditorTemplate 文件绑定到 Kendo UI MVC 中的网格组合框
【发布时间】:2012-09-13 16:04:21
【问题描述】:

假设我在 /Views/Home/Index.cshtml 上的文件上有网格:

 @model IEnumerable<KendoMVCWrappers.Models.StockWebAndDetailsView>

@( Html.Kendo().Grid(Model)

               .Name("Grid")
                @* Other columns and dataSource in here *@
                columns.Bound("QuantityToEnquiry").Filterable(false).Sortable(false)
                     .EditorTemplateName("QuantityToEnquiry"); 

               })

我在 /Views/EditorTemplateName/QuantityToEnquiry.cshtml 上有文件(我也试过 ~/Views/Shared/EditorTemplates/):

 @(Html.Kendo().ComboBox()
        .Name("QuantityToEnquiry")
        .Value("1")
            .BindTo(Enumerable.Range(1, 100).ToList())

在我拥有的模型上:

public class StockWebAndDetailsView
{
    [UIHint("QuantityToEnquiry")]
            public int QuantityToEnquiry { get; set; }
}

显示的数据是null,一个值为“null”的字符串,我不知道为什么。

【问题讨论】:

  • “显示的数据为空”是什么意思?它在下拉列表中吗?使用 Html.DropDownList 时会发生什么?
  • 嗨@AtanasKorchev 它输出一个空字符串,而不是一个组合框。
  • 在这种情况下 Html.DropDownList 输出什么?
  • 同样的输出,好像没有找到文件
  • 你的属性是用 UIHint 属性装饰的吗?除非您使用 UIHint 指定编辑器模板的名称,否则 ASP.NET MVC 将找不到它。

标签: telerik-grid telerik-mvc kendo-ui


【解决方案1】:

哥们,

首先我建议您将该编辑器模板放在 Shared/EditorTemplates 文件夹下。然后我建议您将组合框命名为与您的属性相同的名称。

@(Html.Kendo().ComboBox()
    .Name("QuantityToEnquiry")
    .Value("1")
        .BindTo(Enumerable.Range(1, 100).ToList())

希望对你有帮助。

【讨论】:

  • 感谢@XMR 的回答,但仍然无法正常工作。 :( 我仍然从 Quantity To Enquiry 得到 null
猜你喜欢
  • 1970-01-01
  • 2023-03-06
  • 2018-09-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多