如何使制表符表格单元格仅接受数字并且不允许输入非数字

问题描述 投票:0回答:1

这是我的表格代码,我想重新编写表格以仅接受数字而不接受任何特殊字符

 

table headers and table definition's 
 this.beltTabulatorHeaders = [
            {
                title: "Type", field: "name", headerHozAlign: "left", width: "55%", headerSort: false, hozAlign: "left", editable: false

            },
            {
                title: "Value", headerHozAlign: "center", width: "45%",
                columns: [
                    {
                        title: "Min", field:"minValue",cellEdited: validateBelt, validator:numericValidator,editable:editCheck,editor: "input", headerSort: false, width: "15%", hozAlign: "right", formatter:
                            decimalFormatter
                        , headerHozAlign: "right"
                        , editorParams: {
                            formatter: decimalFormatter,
                        },
                    },
                    {
                        title: "Nom", field: "nomValue",cellEdited: validateBelt, editor: "input", headerSort: false, width: "15%", hozAlign: "right", formatter: decimalFormatter, headerHozAlign: "right"

                        , editorParams: {
                            formatter: decimalFormatter
                        }
                    },
                    {
                        title: "Max", field:"maxValue",cellEdited: validateBelt, editable:editCheck,editor: "input", headerSort: false, width: "15%", hozAlign: "right", formatter: decimalFormatter, headerHozAlign: "right"

                        , editorParams: {
                            formatter: decimalFormatter
                        }
                    },
                ],
            },

        ];
        this.beltTabulatorTable = new Tabulator("#beltTabulatorTable", {
            maxHeight: "100%",
            maxWidth: "100%",
            data: beltTableData,
            layout: "fitDataTable",
            headerSort: false,
            columns: this.beltTabulatorHeaders,
            responsiveLayout: false,
        })

以上是表格代码

javascript angular typescript tabulator
1个回答
0
投票

您可以使用

numeric
编辑器来执行此操作,它将插入数字类型输入而不是文本类型输入:

{title:"Example", field:"example", editor:"number", editorParams:{
    min:0,
    max:100,
    step:10,
}}

完整详细信息可以在编辑器文档

中找到
© www.soinside.com 2019 - 2024. All rights reserved.