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

RadNumeric Textbox in RadGrid Allowing more than 2 decimal Digits

1 Answer 160 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Atchut
Top achievements
Rank 1
Atchut asked on 08 May 2012, 02:17 AM
Hello,

I am having rad numeric textbox in a Radgrid.
I dont want to allow more than 2 digits after decimal. Below is numeric textbox. It is not working.

  <telerik:GridTemplateColumn HeaderText="Price" UniqueName="Price">
                     <ItemTemplate>
                        <telerik:RadNumericTextBox  ID="txtNewPrice" runat="server" MaxLength="10" AutoCompleteType="None"  CssClass="CurPriceTxtbox" 
                                  Width="50px"     Type="Number" ShowSpinButtons="false" AllowOutOfRangeAutoCorrect="false" InvalidStyle-Font-Bold="true">
                                      <NumberFormat AllowRounding="false" DecimalDigits="2"  KeepNotRoundedValue="true" GroupSizes="3"/>
                                      <ClientEvents OnValueChanging="ValueChanged" OnError="HandleError"/>
                                  </telerik:RadNumericTextBox> 
                     </ItemTemplate>
                 </telerik:GridTemplateColumn> 

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 10 May 2012, 10:03 AM
Hello Atchut,

I have tried the provided sample code and everything works as expected on my side. Please keep in mind that NumberFormat-DecimalDigits applies after typing is finished, namely - after the input loses focus.

However, if you want do disable entering dynamically after the second digit, you could use OnKeyPress client event as shown below:
mark-up:
<ClientEvents ... OnKeyPress="keyPressed" />
javascript:
function keyPressed(sender, args) {
     var value = sender.get_value() * 10;
     if (value - parseInt(value) != 0) {
          args.set_cancel(true);
    }
}


Kind regards,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
General Discussions
Asked by
Atchut
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or