asp.net – 剑道:网格中的ComboBox – 将选定组合框的其他数据发送到组合框Read()
发布时间:2020-05-25 08:18:22 所属栏目:asp.Net 来源:互联网
导读:ASP.NET MVC5 我在网格中有一个组合框(InLine Edit): columns.Bound(x=x.AccountID).EditorTemplateName(MyTemplate) MyTemplate在/共享的地方 有数百万的帐户. 当我尝试编辑网格中的组合框并选择新值时,将显示帐户的ID,而不是名称.这是因为当然帐户的名称不
|
ASP.NET MVC5 我在网格中有一个组合框(InLine Edit): columns.Bound(x=>x.AccountID).EditorTemplateName("MyTemplate")
MyTemplate在/共享的地方 有数百万的帐户. 当我尝试编辑网格中的组合框并选择新值时,将显示帐户的ID,而不是名称.这是因为当然帐户的名称不会立即存在,所以在ComboBox.Datasource的Read().Data()中我需要发送额外的数据; AccountID. 我的ComboBox模板如下所示: .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的局部视图中定义的组合框@(Html.Kendo().ComboBox()
.Name("AcctName")//must match Field Name that is being edited
.HtmlAttributes(new { style = "width:250px" })
.DataTextField("AcctName")
.DataValueField("AcctCd")
.Filter(FilterType.StartsWith)
.AutoBind(true)
.MinLength(3)
.DataSource(source =>
{
source.Read(read =>
{
read.Action("GetCombo","GridPost").Data("OnAdditionalData");
})
.ServerFiltering(true);
})
)
这是视图和控制器操作 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调用一样,在代码中放置断点可能会阻止窗口小部件按预期执行.对于前者单击要编辑的字段时使用单元格编辑,如果在GetCombo中放置断点,则ComboBox编辑器模板将无法正确默认为该值. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net-mvc – MVC 5脚手架不为基本EF派生数据发出引导类
- asp.net – 额外的文件夹附加到我的Web根目录在AWS
- asp.net – 在实体框架中使用PersianCalendar作为表列的正确
- asp.net-mvc – 有没有办法重命名RequestVerificationToken
- asp.net – 使用WebAPI时重新验证模型(TryValidateModel等效
- rest – 基于权限从WebApi端点进行上下文序列化
- asp.net-mvc – 用于子操作的ASP.NET MVC路由匹配
- asp.net 2.0中利用Ajax2.0实现JSON传送大量页面数据
- asp.net – 正则表达式验证器 – 动态显示块而不是内联
- asp.net – 您在实施/使用WebDAV方面有哪些经验?
推荐文章
站长推荐
- ASP.NET Cookie过期时间始终是1/1/0001 12:00 AM
- asp.net-mvc – Elmah.MVC在IIS Express下工作但
- asp.net – 可以从Web API访问HttpContext.Curre
- asp.net – 通过使用Javascript将邮政编码传递到
- asp.net-mvc – 如何使用Html.Action?
- asp.net-mvc – 如何用ASP.NET MVC命令查询责任分
- 模型绑定 – WebApi2:自定义参数绑定以绑定部分
- asp.net – GridView中的多个DataKeyNames
- asp.net-mvc – ASP.NET Web Api – 将对象发布到
- asp.net核心 – ASP.NET核心MVC查看组件
热点阅读
