Kendo UI的PopupEditor绑定下拉值 [英] Kendo UI bind drop down value from PopupEditor

查看:153
本文介绍了Kendo UI的PopupEditor绑定下拉值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Kendo网格,它具有使用弹出编辑器添加新记录的选项. 弹出编辑器中的一个字段是DropDownList.打开弹出编辑器时,我从下拉列表中选择了第一条记录.由于我已经预先选择了它,所以我希望在网格中(按更新"时)自动创建(绑定)它而无需再次手动选择. 我在此处有示例脚本

I have a Kendo Grid which has an option to add a new record using the Popup Editor. One field from the popup editor is a DropDownList. I have the first record from the dropdown list pre-selected when I open the Popup Editor. Since I pre-selected it, I would like it to be automatically created (bound) within the grid (when pressing "Update") without having to manually select it again. I have the example script here

推荐答案

工作脚本:以下是一些有用的知识:

Here's a few things that are useful to know:

模式是一种定义期望从数据中获取哪种结构的方法.当定义了模式时,您的数据将被绑定".您将尽可能地绑定数据,因为作为最后的选择,您最终将不得不使用模板.通常,Kendo UI会尝试找出问题并自动绑定,但是在特殊情况下,您必须为其提供一个架构.这是其中一种情况.

A schema is a way to define what structure to expect from your data. When a schema is defined, your data will be "bound". As much as possible you'll want to bind your data, because as a last resort you'll end up having to use templates. Normally, Kendo UI will try to figure things out and get things bound automatically, but in special cases you'll have to give it a schema. This is one of those cases.

从代码示例中看来,变通办法的方法似乎是尝试更改"edit"标签. kendoGrid事件以立即选择"Processing"状态-相反,您可以定义正在处理"状态状态(值"2")作为状态"的默认值.模型中的字段.但是,然后,您需要确保可以将您的自定义编辑器模板绑定到,这将导致我们进入..

From the code sample, it seems like the approach of the workaround was to try change the "edit" event of the kendoGrid to immediately select the "Processing" status - Instead, you can define the "Processing" status (value "2") as the defaultValue of the "status" field in your model. But then, you'll need to make sure your custom editor template CAN be bound to, which leads us to..

为剑道弹出窗口制作自己的编辑器模板时,它无法知道要绑定到HTML的哪一部分.请参阅所提供的链接中的statusDropdownEditorTemplate作为此操作的示例.

When you're making your own editor templates for the kendo popup, it has no way of knowing what part of your HTML to bind to. See the statusDropdownEditorTemplate in the link provided as an example of how this is done.

通常,kendoDropDownList将返回一个对象,其中包含选定选项的文本"和值".但这不是我们在这种情况下想要的,因为状态被定义为"0","1","2". -因此,我们只需要该值.将valuePrimitive设置为true时,将指示kendoDropDownList仅返回值本身,而不返回包含所有内容的对象.

Normally, a kendoDropDownList will return an object containing both the Text and Value of the selected choice. But this is not what we want in this case, because status is defined as "0", "1", "2" - so we just wanted the value. When you set valuePrimitive to true, you're instructing the kendoDropDownList to only return the value itself, not an object containing everything.

这篇关于Kendo UI的PopupEditor绑定下拉值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆