【问题标题】:Kendo UI Web MultiSelect - How should I build the model?Kendo UI Web MultiSelect - 我应该如何构建模型?
【发布时间】:2013-10-21 08:26:50
【问题描述】:

我需要将单个页面链接到多个类别并将关系存储在数据库中。我想通过使用与 Kendo UI Web 捆绑的 MultiSelect 小部件来实现这一点。 CategoryId 是 Category 表中的外键。

理论上,类别应该以类似于 SO 上的标签系统的方式工作。是否有推荐的方法或示例向我展示如何做到这一点?

这是我的页面模型的示例:

public int PageId { get; set; }
public string Title { get; set; }

public int CategoryId { get; set; }
public virtual Category Category { get; set; }

我尝试使用以下方法但无济于事:

public List<int> CategoryId { get; set; }

请注意,我没有使用 MVC Server Wrappers,而是使用 JavaScript 作为视图。任何帮助将不胜感激。

【问题讨论】:

    标签: c# asp.net-mvc entity-framework kendo-ui


    【解决方案1】:

    尝试将列表项从 int 更改为 string:

    public List<string> CategoryId { get; set; }
    

    有关详细信息,请参阅此答案: Kendo Multiselect: Selected values from binded model are not initialized

    【讨论】:

    • 感谢您的回复。我试了一下,与使用 List 的问题相同。加载图标出现,类别不显示。让我仔细看看你发布的问题。也许我应该采用 ViewModel 方法。
    猜你喜欢
    • 1970-01-01
    • 2012-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多