jQWidgets Forums

jQuery UI Widgets Forums Grid Handle keyboard

This topic contains 1 reply, has 2 voices, and was last updated by  Hristo 9 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • Handle keyboard #82597

    rajnagthi123
    Participant

    Hi Peter,

    I want to restrict the user by entering 5 digit and 2 decimal numbers.

    I am using JQXNumber Input inside grid (used like editor.jqxnumberinput), the properties (digits, decimal digits) which are given to achieve the expectation is not working in my grid.

    Meanwhile I am using handlekeyboard event to suppress the non-numeric characters.

    Is there is any possibility to achieve number of digit restriction inside handlekeyboard event.

    I tried to achieve number of digit restriction in this event using regular expression (for ex: d{0,5}.d{0,2})

    can I get the cursor position from where user had triggered keypress (or) can I get the new value of the cell in this event so that I will match with the regex and suppress the keypress.

    Regards,
    Rajkumar

    Handle keyboard #82613

    Hristo
    Participant

    Hello Rajkumar,

    Could you try to validate value in member “validation” in ‘columns’ property.
    Add something similar like:

    
    columntype: 'numberinput',
    validation: function (cell, value)
    {
        var hasCorrectDigits = (value / 10000 | 0) != 0;
        var hasCorrectDecimal = value % 1 != 0;
        if (!hasCorrectDigits || !hasCorrectDecimal)
        {
             return { result: false, message: "Must be with correct size" };
        }
    
        return true;
    },
    initeditor: function (row, cellvalue, editor) {
        editor.jqxNumberInput({ digits: 5, decimalDigits: 2 });
    },

    Best Regards,
    Hristo Hristov

    jQWidgets team
    http://www.jqwidgets.com

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.