kendo-grid - 如何在剑道网格单元中创建kendoNumericTextBox?

标签 kendo-grid kendo-template kendonumerictextbox

有什么方法可以在剑道网格单元模板中创建小部件吗?这是示例代码。

columns: [{
    field: "Name",
    title: "Contact Name",
    width: 100
},
{
    field: "Cost",
    title: "Cost",
    template: "<input value='#: Cost #'> </input>",// input must be an numerical up down.

}]

我想为成本列创建一个上下数字。

这是demo

最佳答案

在字段定义中使用“编辑器”属性。您必须指定一个函数,将小部件附加到行/绑定(bind)单元格。

下面是我在网格的每一行中放置一个下拉列表的示例:

$('#grdUsers').kendoGrid({
        scrollable: true,
        sortable: true,
        filterable: true,
        pageable: {
            refresh: true,
            pageSizes: true
        },
        columns: [
            { field: "Id", title: "Id", hidden: true },
            { field: "Username", title: "UserName" },
            { field: "FirstName", title: "First Name" },
            { field: "LastName", title: "Last Name" },
            { field: "Email", title: "Email" },
            { field: "Team", title: "Team", editor: teamEdit, template: "#=Team ? Team.Name : 'Select Team'#" },
            { command: { text: "Save", click: saveEmployee }, width: '85px' },
            { command: { text: "Delete", click: deleteEmployee }, width: '85px' }
        ],
        editable: true,
        toolbar: [{ name: "create-user", text: "New Employee" }]
    });

       function teamEdit(container, options) {
        $('<input required data-text-field="Name" data-value-field="Id" data-bind="value:' + options.field + '"/>')
            .appendTo(container)
            .kendoDropDownList({
                autoBind: false,
                optionLabel: {
                    Name: "Select Team",
                    Id: ""
                },
                dataTextField: "Name",
                dataValueField: "Id",
                dataSource: model.getAllTeams()
            });
    }

关于kendo-grid - 如何在剑道网格单元中创建kendoNumericTextBox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23245678/

相关文章:

kendo-ui 网格列模板函数字段名称

css - kendo-ui 中用于 angular2 的样式输入组件

javascript - 使用 kendoui 和 jquery 双击禁用 kendo numerictextbox 小部件

asp.net-mvc - Kendo:处理Ajax数据请求中的错误

javascript - 如何阻止 Kendo KO Grid 自动滚动

angularjs - 来自内联模板的带有剑道工具提示的剑道网格不起作用

javascript - Kendo UI 中毫秒是否为 000 的条件模板

javascript - Kendo Grid 工具栏项目未触发单击功能 :

asp.net-mvc - Kendo网格不显示任何数据

kendo-ui - kendo ui,角度需要验证数字文本框