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

[Solved] Logic Differences when Client API used?

2 Answers 101 Views
NumericTextBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jay
Top achievements
Rank 1
Jay asked on 18 May 2011, 02:57 PM
It seems that the logic used when a value is set by hand, and the logic used with the client Api is used is slightly different.

Say I have a numeric Textbox on the page.  Like this:
@(Html.Telerik().NumericTextBox()
    .Name("SomeField")
    .MaxValue(12)
    .MinValue(1)
    .DecimalDigits(0)
    .EmptyMessage("")
)


And I make an API call:
 
$("#SomeField").data("tTextBox").value(128);


The field will be set to a null value, and no valueChange event will fire.

On the other hand, if I type in by hand, and blur.  The textbox will change itself back to 12, and fire off two valueChange events.  One for the set to 128, and the other for itself autocorrecting to 12. 

I found that if I modify the file telerik.textbox.js and comment out these lines (Approx around line 423) that the api works as expected.   But I'm not sure what I'm breaking by doing that.

if (!this.inRange(parsedValue, this.minValue, this.maxValue)) {
    parsedValue = null;
}

2 Answers, 1 is accepted

Sort by
0
Jay
Top achievements
Rank 1
answered on 18 May 2011, 03:18 PM
You know what I did find useful though?  Was taking that above "if" statement, and using it where the two valueChange events are fired to verify validity of the value fired.

So when valueChange is fired, the object holds a "valid" flag.  Which would be false for the "128" or true for the "12" that comes after.

I think it'd be more useful to trap the events, and if the value is 12, and it's set to 128, then automatically back to 12, no event at all is fired.  Because the value ended up not changing.
0
Georgi Krustev
Telerik team
answered on 20 May 2011, 11:32 AM
Hello Jeff,

 
Currently valueChange event is fired when the value is changed even when it is out of range. When user types 128, even that the value is out of range it is valid number and the value actually is changed, that is why the valueChange is raised.

I have logged your request to our product backlog for further consideration. Depending on the users interest we will decide to change current behavior. 

Best 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
Tags
NumericTextBox
Asked by
Jay
Top achievements
Rank 1
Answers by
Jay
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or