1

我在我的 asp.net mvc 4 中使用带有剃刀视图的 kendo ui,当列表从通过 ajax 的操作加载并像此处的示例一样向服务器发送参数时遇到 kendo 组合问题:HERE 因为表有超过 2,000行。

当我加载编辑页面时,组合按预期加载和过滤数据,但该字段的值是 - [object object]。

我确实声明了 .DataTextField("ProoffName") + .DataValueField("ID")

我的客户控制器:

public ActionResult Edit(int id = 0)
    {
        Clients clients = db.Clients.Find(id);
        if (clients == null)
        {
            return HttpNotFound();
        }
        ViewData["MyAgency"] = new SelectList(db.Agency, "ID", "AgentName", clients.AgencyId);
        ViewData["MyCategory1"] = new SelectList(db.CategoryTbl, "ID", "category", clients.CategoryId);

        List<SelectListItem> obj = new List<SelectListItem>();
        obj.Add(new SelectListItem { Text = "male", Value = "1" });
        obj.Add(new SelectListItem { Text = "female", Value = "2" });
        obj.Add(new SelectListItem { Text = "choose", Value = "0" });
        ViewData["MyMin"] = obj;

        ViewBag.ProffID = new SelectList(db.ProfTBL, "ID", "ProffName", clients.ProffID);
        ViewBag.Metapel = new SelectList(db.Workers, "ID", "WorkerName", clients.Metapel);
        return View(clients);
    }

我的 ProffController:

public ActionResult ProffVM_Read(string text)
    {
        var Proff_Tbl = db.ProfTBL.Select(proff => new ProffVm { ID = proff.ID, ProffName = proff.ProffName });
        if (!string.IsNullOrEmpty(text))
        {
            Proff_Tbl = Proff_Tbl.Where(p => p.ProffName.Contains(text));
        }
        return Json(Proff_Tbl, JsonRequestBehavior.AllowGet);
    }

和剑道组合:

@Html.Label("Proff")
                            @(Html.Kendo().ComboBoxFor(model => model.ProffID)
                              .Name("proffCbo")
                              .DataTextField("ProffName")
                              .DataValueField("ID")
                              .Events(e => e
                                    .Select("proffCbo_select")
                                    .Change("proffCbo_change")
                                )
                              .DataSource(source =>
                              {
                                  source.Read(read =>
                                  {
                                      read.Action("ProffVM_Read", "Proff")
                                               .Data("onAdditionalData");
                                  });
                              })
                            )

我哪里错了???我可以将此组合更改为文本框,但...我必须实现魔力。

谢谢

4

1 回答 1

0

改变这两行

var Proff_Tbl = db.ProfTBL.Select(proff => new ProffVm { ID = proff.ID, ProffName = proff.ProffName });

Proff_Tbl = Proff_Tbl.Where(p => p.ProffName.Contains(text));

var Proff_Tbl = db.ProfTBL.Select(proff => new ProffVm { ID = proff.ID, ProffName = proff.ProffName }).ToList();

Proff_Tbl = Proff_Tbl.Where(p => p.ProffName.Contains(text)).ToList();
于 2013-11-08T16:09:19.810 回答