This is a migrated thread and some comments may be shown as answers.

[Solved] CurrencyTextBox Max/Min Bug in grid?

4 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Emmanuel
Top achievements
Rank 1
Emmanuel asked on 29 Apr 2011, 08:47 PM
Hi.
I believe I have found a small bug, and have done a sample project.
Here is an example:
I have a batch editing grid that has many CurrencyTextBox / PercentTextBox element types.
These control templates are, as in the demo example, in Views/Shared/EditorTemplates.

Normally, a CurrencyTextBox or PercentTextBox that has a Max or Min value set and we enter outside those boundries, the control will automatically reset the value to an acceptable range.

In a Grid however, when the value in a CurrencyTextBox or PercentTextBox goes out of range:
1 - Yes the control background turns red to signal an error
2 - When we unselect the control, the red background, disapears.
3 - No validation message pops up
4 - The value is never automatically set to an acceptable range

I can actually try and save the invalid data. Of course the validation on the server side detects an error and stops the process from going any further, sending back a proper error message, but this I think should be caught on the client side.

You can see the error in the http://localhost:7777/grid/editingbatch page.
I added a Max field of 5000 to the template in Views/Shared/EditorTemplate/Currency.ascx

<%= Html.Telerik().CurrencyTextBox()
        .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .InputHtmlAttributes(new {style="width:100%"})
        .MinValue(0)
        .MaxValue(5000)
        .Value(Model)
%>

I added a control with the same parameters (Min/Max) outside the Grid so you can see the difference.

Try and go over 5000 in the CurrencyTextBox outside the Grid.
Try and go over 5000 in the Grid's "Unit Price" column.

-Emmanuel

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 02 May 2011, 10:37 AM
Hello Emmanuel,

Thank you for pointing this issue.

After further investigation we was not able to find feasible fix of this problem. What can I offer you is a workaround of this issue. Here is a code snippet which fix this erroneous behavior:

function Grid_Save(e) {
    var cell = $(e.cell),
        $numeric = cell.find(".t-numerictextbox .t-input");
 
    if ($numeric.length) {
        var numeric = $numeric.blur().data("tTextBox");
        if (e.values[$numeric.attr("name")]) {
            e.values[$numeric.attr("name")] = numeric.value();
        }
    }
}
In order to use it, you should wire OnSave client event.

As a gratitude of your feedback I have updated your Telerik points.

Regards,

Georgi Krustev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Emmanuel
Top achievements
Rank 1
answered on 02 May 2011, 02:55 PM
Thank you for the workaround, it seems to work well.

-Emmanuel
0
Emmanuel
Top achievements
Rank 1
answered on 03 May 2011, 04:51 PM
Actually this does not seem to work at all in IE 9 or IE 9 Compatability Mode...
0
Emmanuel
Top achievements
Rank 1
answered on 03 May 2011, 05:01 PM
This function is good with IE:

function Grid_Save(e) {
    var cell = $(e.cell),
        $numeric = cell.find(".t-numerictextbox .t-input");
    
    if ($numeric.length) {
        var numeric = $numeric.blur().data("tTextBox");
            if (e.values[$numeric.attr("name")]) {
            var valueToUse = numeric.value();
            if(valueToUse > numeric.maxValue)
                e.values[$numeric.attr("name")] = numeric.maxValue;
            else if(valueToUse < numeric.minValue)
                e.values[$numeric.attr("name")] = numeric.minValue;
            else
                e.values[$numeric.attr("name")] = valueToUse;
        }
     }
}
Tags
Grid
Asked by
Emmanuel
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Emmanuel
Top achievements
Rank 1
Share this question
or