【问题标题】:Kendo numeric textbox in grid with Angular带有角度的网格中的剑道数字文本框
【发布时间】:2015-12-04 18:40:16
【问题描述】:

我正在尝试在 Angular 中的剑道网格内使用来自剑道的数字文本框。用我的角度对象绑定数据不起作用。我试图在列对象中放置一个“编辑器”字段,或者甚至使用 jQuery 命令(我知道这很糟糕)来做到这一点:

$('.editable').kendoNumericTextBox()

但它永远不会起作用..

【问题讨论】:

    标签: angularjs kendo-ui kendo-grid


    【解决方案1】:

    不要在列对象中使用模板,而是使用editor属性:

    {
        field: "fieldName",
        title: "Field Title",
        width: "90px",
        editor: numberEditor
    }
    

    numberEditor 是一个函数,你可以实现如下:

    function numberEditor(container, options) {
      $('<input name="' + options.field + '"/>')
      .appendTo(container)
      .kendoNumericTextBox({
        decimals: 0,   // Settings for the editor, e.g. no decimals
        step    : 1,   // Defines how the up/down arrows change the value
        min     : 0    // You can also define min/max values
    });
    

    }

    【讨论】:

    • 谢谢。我试过这个,但是当我这样做时,我松开了我的角度对象的绑定。我的角度对象有点复杂,无法直接通过options.field访问值。我通过使用 schema 和 type="number" 找到了我的解决方案
    猜你喜欢
    • 1970-01-01
    • 2013-04-17
    • 1970-01-01
    • 1970-01-01
    • 2013-02-20
    • 1970-01-01
    • 1970-01-01
    • 2015-10-03
    • 1970-01-01
    相关资源
    最近更新 更多