1

我正在尝试使用名为 combobox 的 ignite ui 组件,并且我试图在 igniteui 页面上遵循本教程。

这是链接: http ://www.igniteui.com/combo/aspnet-mvc-helper

本教程使用存储库工厂,我正在使用带有 linq 的实体框架模型。我已经使用了一些 ignite ui 的组件,比如 igGrid,并且我按照这个视频的教程进行操作

http://www.infragistics.com/products/jquery/grid/videos/iggrid-entity-framework-model 使网格与 ef 模型绑定。

我在将数据绑定到组合框时遇到问题,我试图对 iggrid 的 bing 采用相同的方法,但我遇到了一些问题..

在我看来,我有这个..

 @(Html.Infragistics().ComboFor(item=>item.IDCliente)

                .Width("270px")
                .DataSourceUrl(Url.Action("cliente-combo-data"))
                .ValueKey("ID")
                .TextKey("Name")
                .DataBind()
                .Render()
            )

在控制器中我有这个:

    [ComboDataSourceAction]
    [ActionName("cliente-combo-data")]
    public ActionResult ComboData()
    {
        return View(LicenciamentoMVC.Models.ClienteModel.GetListaClientes());
    }

在我的客户班我有这个:

 public class ClienteModel
{
    private static Cliente entity;
    public static IQueryable<Cliente> GetListaClientes()
    {
        MvcApplication1Context db = new MvcApplication1Context();

        var customers = from c in db.Clientes
                        orderby c.IDCliente descending
                        where c.Rem==0
                        select c;

        return customers.AsQueryable<Cliente>();
    }

给我的错误是:“ System.Collections.Generic.IEnumerable”不包含“IDCliente”的定义,并且没有接受“System.Collections.Generic.IEnumerable”类型的第一个参数的扩展方法“IDCliente”可能是找到(您是否缺少 using 指令或程序集引用?)

我需要做些什么改变,或者最好的方法是不要使用实体模型去存储库......提前谢谢......

4

1 回答 1

2

解决方案是更改我在视图中初始化组合框的方式,我正在关注 igniteui 教程,并且他们在组合上放置的示例对于如何使用组合框的示例/教程来说有点复杂......这是带有助手的 mvc 的代码

@(Html.Infragistics().Combo().
              ID("comboClientes").
              TextKey("Nome").
              AutoComplete(false).
              FilteringType(ComboFilteringType.Local).
              RenderMatchItemsCondition(ComboRenderMatchItemsCondition.StartsWith).
              ValueKey("IDCliente").DataSourceUrl(Url.Action("clientes-combo")).
              DataBind().
              Render())

谢谢

于 2014-02-06T11:23:15.463 回答