Ext.net号码字段

时间:2013-01-10 05:23:54

标签: ext.net

如何设置最大十进制值= .45 我想选择小时数...即

1.15 hrs
1.30 hrs
1.45 hrs
2.00 hrs 
'
'
'

等等

                   <ext:NumberField 
                        ID="numHours" 
                        runat="server" 
                        ColumnWidth="0.2" LabelWidth="50"
                        MinValue="0"
                        MaxValue="12"
                        AllowDecimals="true"
                        DecimalPrecision="2"
                        Step="0.15"
                        />

1 个答案:

答案 0 :(得分:1)

也许是这样的。

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>

<html>
<head runat="server">
    <title>Ext.NET v2 Example</title>

    <script>
        var onChange = function (field, newValue, oldValue) {
            if (newValue % 1 > 0.45) {
                if (newValue > oldValue) {
                    newValue += 0.4;
                } else {
                    newValue -= 0.4;
                }
            }

            this.setValue(newValue);
        };
    </script>
</head>
<body>
    <form runat="server">
        <ext:ResourceManager runat="server" />

         <ext:NumberField 
            runat="server" 
            MinValue="0"
            MaxValue="12"
            AllowDecimals="true"
            DecimalPrecision="2"
            TrimTrailedZeros="false"
            Step="0.15">
            <Listeners>
                <Change Fn="onChange" />
            </Listeners>
         </ext:NumberField>
    </form>
</body>
</html>

虽然,就个人而言,我也会考虑使用SpinnerField的可能性。这是一个example