【问题标题】:Kendo numeric text box min max values not working剑道数字文本框最小值最大值不起作用
【发布时间】:2020-01-01 05:44:34
【问题描述】:

我在指令中有一个 Kendo 数字文本框。即使我设置了最小和最大字段,用户也可以输入超出范围的值。这是模板字符串:

public template: string = '<input name = "numberField" type="text" id="searchIntNumberBox{{hashkey}}" required="required" ng-model="number" kendo-numeric-text-box k-options="options"' +
                               'min="{{minimumValue}}" max="{{maximumValue}}" maxlength = "{{maximumLength}}" step="5" style="width: 100%;height:26px"" />';

这是选项

$scope.options = {
            decimals: 0,
            format: '#',
            spin: (e) => {
                const value = e.sender.value();
                $scope.number = value;
                $scope.$apply();
            },
        };

谁能告诉我我做错了什么。最小值为 0,最大值为 2147483647,但我可以输入负值,也可以输入高于最大值的值。

【问题讨论】:

  • 您可以为您的问题创建工作演示吗?
  • 看看documentation,看看它是否对你有帮助。

标签: javascript angularjs typescript kendo-ui


【解决方案1】:

在使用html格式的剑道设置时需要添加“k-”:

 public template: string = '<input name = "numberField" type="text" id="searchIntNumberBox{{hashkey}}" required="required" ng-model="number" kendo-numeric-text-box k-options="options" k-min="minimumValue" k-max="maximumValue" maxlength = "{{maximumLength}}" step="5" style="width: 100%;height:26px"" />';

或在控制器中:

$scope.options = {
            decimals: 0,
            format: '#',
            spin: (e) => {
                const value = e.sender.value();
                $scope.number = value;
                $scope.$apply();
            },
            min:yourMinValue,
            max:yourMaxValue
        };

【讨论】:

    猜你喜欢
    • 2022-01-07
    • 1970-01-01
    • 2015-04-08
    • 2022-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-19
    • 1970-01-01
    相关资源
    最近更新 更多