Asp.net 剑道:网格中的ComboBox-将所选ComboBox的附加数据发送到ComboBox Read()

Asp.net 剑道:网格中的ComboBox-将所选ComboBox的附加数据发送到ComboBox Read(),asp.net,kendo-ui,asp.net-mvc-5,kendo-asp.net-mvc,Asp.net,Kendo Ui,Asp.net Mvc 5,Kendo Asp.net Mvc,ASP.NET MVC5 我在网格内联编辑中有一个组合框: columns.Bound(x=>x.AccountID).EditorTemplateName("MyTemplate") MyTemplate位于/共享的位置 有数以百万计的帐户 当我尝试在网格中编辑组合框并选择一个新值时,会出现帐户ID,而不是名称。这当然是因为帐户的名称不会立即出现在ComboBox.Datasource的Read.Data中,所以我需要发送额外的数据;帐户ID 我的组合框模板如下所示: .DataSou

ASP.NET MVC5

我在网格内联编辑中有一个组合框:

columns.Bound(x=>x.AccountID).EditorTemplateName("MyTemplate")
MyTemplate位于/共享的位置

有数以百万计的帐户

当我尝试在网格中编辑组合框并选择一个新值时,会出现帐户ID,而不是名称。这当然是因为帐户的名称不会立即出现在ComboBox.Datasource的Read.Data中,所以我需要发送额外的数据;帐户ID

我的组合框模板如下所示:

.DataSource(source=>
   source.Read(read =>
      read.Action("ReadAccounts".....)
         .Data("HERE IS WHERE I NEED TO SEND THE ACCOUNT ID AS EXTRA DATA 
             WHEN THIS CBO TEMPLATE IS IN A GRID")

谢谢

这是在~/Views/Shared/EditorTemplates/ComboBoxTemplate中的局部视图中定义的组合框

下面是视图和控制器操作

columns.Bound(x => x.AcctName).Title("Acct Name").EditorTemplateName("ComboBoxTemplate");

 function OnAdditionalData() {          

            var entityGrid = $("#ProposalGridX").data("kendoGrid");
            var selected = entityGrid.dataItem(entityGrid.select());
            //if the id is off the Grid Row and not the ComboBox
            //select the row and pull the fields
            //selected.PropertyName

            return {
                text : $("#AcctName").data("kendoComboBox").text(),
                 val : $("#AcctName").data("kendoComboBox").value()
            };
        }

   public JsonResult GetCombo(string text, string val)
   {
         List<PortfolioViewModel> model = new AUMBusiness().GetAum(DateTime.Now);

           if (!string.IsNullOrEmpty(text))
            {
               model = model.Where(x => x.AcctName.StartsWith(text)).ToList();
            }

         return Json(model, JsonRequestBehavior.AllowGet);
    }

与任何Ajax调用一样,在代码中放置断点可能会阻止小部件按预期执行。例如,在单击要编辑的字段时使用incell编辑,如果在GetCombo中放置断点,ComboBox编辑器模板将无法正确默认该值

问题是如何将所选组合框的值和测试发送到.Data。当它们在网格中时,我如何获取它们?看看我的编辑,它基本上是使用内联编辑器模板中的下拉菜单复制粘贴的代码,并捕获要捕获的更改事件、ddlId和rowId。你应该能够让它为你的场景工作。我不知道这是否有用@Bahai,我修改了我的答案并发布了所有相关代码。进入编辑模式时,将填充组合框编辑器,并允许您传递任何字段/值以及组合框的搜索文本。
columns.Bound(x => x.AcctName).Title("Acct Name").EditorTemplateName("ComboBoxTemplate");

 function OnAdditionalData() {          

            var entityGrid = $("#ProposalGridX").data("kendoGrid");
            var selected = entityGrid.dataItem(entityGrid.select());
            //if the id is off the Grid Row and not the ComboBox
            //select the row and pull the fields
            //selected.PropertyName

            return {
                text : $("#AcctName").data("kendoComboBox").text(),
                 val : $("#AcctName").data("kendoComboBox").value()
            };
        }

   public JsonResult GetCombo(string text, string val)
   {
         List<PortfolioViewModel> model = new AUMBusiness().GetAum(DateTime.Now);

           if (!string.IsNullOrEmpty(text))
            {
               model = model.Where(x => x.AcctName.StartsWith(text)).ToList();
            }

         return Json(model, JsonRequestBehavior.AllowGet);
    }