We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ej.Grid.EditingType.Numeric should not allowed negative numbers(like -1,-2,etc..)

hello,

we use field like port number

{ field: "port", headerText: "portNumber", editType: ej.Grid.EditingType.Numeric},

this is working fine but it allows negative numbers(like -1,-2).

i do not want to allow negative number.
so is there any way which allows only positive numbers and 0.

please do not use validationRules.
we do not require at validation time. 

1 Reply

PK Prasanna Kumar Viswanathan Syncfusion Team September 24, 2015 11:44 AM UTC

Hi Rakesh,

Thanks for contacting Syncfusion Support.

Your requirement have been achieved by the editParams property of ejGrid. To avoid negative numbers in numeric textbox, we suggest you to intialize minValue as 0 in editParams.

Please find the following code example and sample,

<script type="text/javascript">

        $(function () {

            $("#Grid").ejGrid({

                // the datasource "window.gridData" is referred from jsondata.min.js

                dataSource: window.gridData,

                allowPaging: true,

                editSettings: { allowEditing: true, allowAdding: true, allowDeleting: true },

                toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.Add, ej.Grid.ToolBarItems.Edit, ej.Grid.ToolBarItems.Delete, ej.Grid.ToolBarItems.Update, ej.Grid.ToolBarItems.Cancel] },

                columns: [

                       { field: "OrderID", headerText: "Order ID", isPrimaryKey:true, textAlign: ej.TextAlign.Right, width: 65 },

                       { field: "CustomerID", headerText: "Customer ID", width: 90 },

                       { field: "ShipCity", headerText: "Ship City", width: 90 },

                       { field: "Freight", headerText: "Freight", width: 90, textAlign: ej.TextAlign.Right, format: "{0:C}", editType: ej.Grid.EditingType.Numeric, editParams: { minValue: 0 } },

                       { field: "ShipCountry", headerText: "Ship Country", width: 90 },

                       { field: "EmployeeID", headerText: "Employee ID", width: 90, textAlign: ej.TextAlign.Right }

                ]

            });

        });
    </script>


 Sample Link: http://www.syncfusion.com/downloads/support/forum/120524/ze/Html_Encode_Feature1899179791

Regards,
Prasanna Kumar N.S.V

Loader.
Up arrow icon