Welcome Guest Search | Active Topics | Sign In | Register

MaskedEdit Number Min/Max Value Issue Options
Steve
Posted: Thursday, March 29, 2012 3:37:22 PM
Rank: Member
Groups: Member

Joined: 12/2/2010
Posts: 10
I have an EO grid control with several MaskedEdit columns each with one segment with the following properties....

Decimals: 1
MaxValue: 24
MinValue: 0
SegmentType: Number

I have three issues...

1. I want to set MinValue to -24. When I attempt to do this however, the designer reverts the value back to 0.

2. When running the application, if I enter a value greater than 24, the control rounds it down to 24.9 instead of to the MaxValue.

3. The grid is in FullRowMode. I can press ENTER and enter values in the cells as expected. If I leave edit mode and re-enter, when I attempt to edit the value in a cell with existing data, all keystrokes go into the tenths decimal place even though the entire value appears highlighted. It is necessary to press DELETE and remove the existing value before I can type a new one. Can the grid be made to replace the existing entry without having to press DELETE?
eo_support
Posted: Thursday, March 29, 2012 5:13:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

To solve both issues, you might want to use a simple TextBoxColumn and then handle the column's ClientSideEndEdit event with JavaScript, then validate your value in your JavaScript handler. Your code would be something like this:

Code: HTML/ASPX
<eo:Grid .....>
    ....
    <Columns>
        ....
        <eo:TextBoxColumn ClientSideEndEdit="on_end_edit" ... />
        ....
    </Columns>
    ....
</eo:Grid>


Code: JavaScript
function on_end_edit(cell, newValue)
{
    //Convert the string value to number and clear
    //the cell (by returning "") if it is not a number
    var n = parseInt(newValue);
    if (isNaN(n))
        return "";

    //Correct the number if it is out of range
    if (n < -24)
        n = -24;
    else if (n > 24)
        n = 24;
    
    //Return the new value. This is the "accepted" cell value
    return n.toString();
}


The idea is this is a "post correction" that lets user enter anything and then correct it rather than using a MaskedEdit to restrict what letter the user can enter. The MaskedEdit is rather limited because it doesn't know when you are going to complete the input. On the other hand, the "post correction" method allows you to implement any validation logic. It also free you up from some unwanted keydown/keyup/focus event maneuvering that the MaskedEdit has to do.

Hope this helps.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.