RadGrid + GridTemplateColumn + RadNumericTextBox

5 posts, 1 answers
  1. Eric
    Eric avatar
    19 posts
    Member since:
    May 2009

    Posted 21 Jan 2011 Link to this post

    Hi all,

    I'm having trouble trying to get the client event "ValueChanged" of the RadNumericTextBox to fire when AllowOutOfRangeAutoCorrect is set to false. I have my RadNumericTextBox inside a GridTemplateColumn from the RadGrid. The JS function is never called.

    Here's how my code looks like:

    <telerik:GridTemplateColumn HeaderText="Qty" DataField="Quantity" UniqueName="Quantity">
                    <ItemTemplate>
                        <telerik:RadNumericTextBox ID="quantity" runat="server"
                            DataType="System.Int32"     
                            AllowOutOfRangeAutoCorrect="false"                
                            MinValue='<%# Decimal.Parse(Eval("MinimumQuantity").ToString()) %>'
                            DbValue='<%# Convert.ToInt32(Eval("Quantity")) %>'
                            Type="Number"
                            SelectionOnFocus="SelectAll"
                            NumberFormat-DecimalDigits="0">
                            <ClientEvents OnValueChanged="OnClientValueChanged" />
                        </telerik:RadNumericTextBox>
                    </ItemTemplate>
                </telerik:GridTemplateColumn>

    <script type="text/javascript">
            function OnClientValueChanged(sender, args)
            {
                 alert("hello");
             //do something
            }
    </script>

    Thanks in advance!

    Eric
  2. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 26 Jan 2011 Link to this post

    Hi Eric,

    I tried to replicate the described issue but to no avail. I ran the page attached to this message with the latest version of RadControls and the value changed event fires as expected when the textboxes lose focus after their values are modified.

    Please, take a look at the attached page and try to modify it until it starts replicating the problemmatic behavior. Then post the modifications that you made and we will inspect it locally.

    All the best,
    Tsvetina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Eric
    Eric avatar
    19 posts
    Member since:
    May 2009

    Posted 27 Jan 2011 Link to this post

    Actually, I beleive I found out what the problem is, but I don't know how to solve it. If we take your example (Default.aspx), valueChanged will only be fired when the value entered is greater or equal to the RadNumericTextBox's MinValue. When it is less than the MinValue, valueChanged is not fired.

    That being said, how can I make this work even when the value entered is less than the MinValue?

    Thx,
    Eric
  4. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 01 Feb 2011 Link to this post

    Hello Eric,

    It is expected that the event is not fired because the value is indeed unchanged. You can instead wire the OnValueChanging event which is fired before the new value is validated and eventually rejected.

    Best wishes,
    Tsvetina
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  5. Eric
    Eric avatar
    19 posts
    Member since:
    May 2009

    Posted 01 Feb 2011 Link to this post

    OnValueChanging worked. Didn't know we could access the new and old value in this event. Should have look into it though...

    Thanks again Tsvetina!
Back to Top