Kendo 网格单元格作为常规文本框而不是 kendoNumericTextboxes

Kendo grid cells as regular textboxes instead of kendoNumericTextboxes

我正在尝试填充可编辑的 kendo 网格。在所有示例中,我看到例如http://demos.telerik.com/aspnet-mvc/grid/editing-inline ,内联编辑器单元格似乎通常显示为 kendoNumericTextBox。

我正在寻找例如在这个例子中(批准的答案)Kendo UI Grid Conditional editing,通过以下方式访问它:

e.container.find("input[name=DiscountPercentageMRC]").data("kendoNumericTextBox")

除了这个 jsFiddle,我无法以这种方式访问​​数字文本框。问题出在哪里?

从问题的两个版本来看,我假设您在问为什么有时编辑文本框是 Kendo UI 文本框(例如 NumericTextBox 或 Kendo-UI 样式的输入),有时是普通输入。

当使用 Kendo UI MVC 网格包装器时,编辑器小部件依赖于以下内容:

  • 特定数据字段类型的默认 ASP.NET MVC 编辑器。
  • 放置在 /EditorTemplates/ 个文件夹中的编辑器模板文件。

可能您的应用程序中没有 Kendo UI 编辑器模板文件,这就是为什么在编辑模式下不使用 Kendo UI 小部件的原因。请验证。

内置 Kendo UI 编辑器模板在 "UI for ASP.NET MVC" 安装的 wrappers/aspnetmvc/EditorTemplates 文件夹中可用。

http://docs.telerik.com/kendo-ui/aspnet-mvc/introduction#distribution-contents

以下是如何使用它们或创建您自己的编辑器模板:

http://docs.telerik.com/kendo-ui/aspnet-mvc/helpers/grid/templating/editor-templates

将 Kendo UI 小部件用作编辑器后,您可以在网格的 edit 事件中访问它们,如下所示:

http://docs.telerik.com/kendo-ui/controls/data-management/grid/how-to/Editing/access-editor-control

纯文本框编辑器和 Kendo-UI 样式的纯文本输入可通过相应的字段名称作为标准 input 元素进行访问。不需要 .data('kendoWidgetName') 方法:

var productNameTextBox = e.container.find("[name=ProductName]");