dojo empty numbertextbox正在显示NaN,但我不想要它的默认值

时间:2014-03-06 08:24:27

标签: dojo numbers dojox.grid.datagrid

我在Datagrid中有一个可编辑的numbertextbox。如果它是空的,它显示NaN,但我不想要它的默认值 它应该是这样的(空白)。请帮我。我怎样才能在道场实现这一目标?

1 个答案:

答案 0 :(得分:1)

尝试设置约束参数,如下所示:

var myNumberBox = new dijit.form.NumberTextBox({
    constraints: { pattern: "0.####" },  // The pattern that the number will be displayed or set as
    value: "",       // The starting value if a value isn't set from any other source
    required: false, // You may want to set this to true if user input is required
    placeHolder: "(blank)" // What is shown when no value is present
});

每当您获得数字框的值时,您可能希望首先通过parseInt(value)或parseFloat(value)传递它。还要检查它是否是一个数字。

var value = parseFloat(myNumberBox.get("value"));
if ( isNan(value) ) {
    // Code to handle if it is NaN
}

如需更多帮助,请转到link

我希望这会有所帮助。