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

Telerik RadNumericTextBox not returning updated value which is set from client side javascript

3 Answers 295 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Himanshu
Top achievements
Rank 1
Himanshu asked on 24 Dec 2013, 07:27 AM
i have created a RadNumericTextBox inside a Talerik Rad Grid Edit form template as below:

<pre lang="xml">&lt;telerik:RadNumericTextBox ID=&quot;rdtbTPCCommissionAmount&quot; DataType=&quot;System.Decimal&quot;
                                                EnabledStyle-HorizontalAlign=&quot;Right&quot; Type=&quot;Number&quot; NumberFormat-DecimalDigits=&quot;2&quot;
                                                ReadOnly=&quot;true&quot; AutoPostBack=&quot;false&quot; CssClass=&quot;amountDueWidth disableInputStyle&quot;
                                                runat=&quot;server&quot; NumberFormat-AllowRounding=&quot;true&quot; Style=&quot;width: 100% !important;&quot;
                                                Width=&quot;100%&quot;&gt;
                                                &lt;IncrementSettings InterceptMouseWheel=&quot;false&quot; InterceptArrowKeys=&quot;false&quot; /&gt;
                                            &lt;/telerik:RadNumericTextBox&gt;</pre
On a another RadNumericTextBox blur event i calling a Javascript funtion as below:
<pre lang="xml">function validateThirdPartyCommissionRate(){
               validateThirdPartyRate(&quot;&lt;%= rgThirdPartyCommissions.ClientID %&gt;&quot;);
           }</pre>
From this above funtion i am calling a method written in JS file like below and setting some value to that RadNumericTextBox:

<pre lang="cs">function validateThirdPartyRate(radGridId) {
    var grid = $find(radGridId).get_element();
    var commissionAmt = $telerik.findElement(grid, &quot;rdtbTPCCommissionAmount&quot;);</pre>
<pre lang="cs">var calculatedAmount = parseFloat(rate) * parseFloat(premiumFeeAmt) / 100;
           commissionAmt._setNewValue(calculatedAmount);
           $(&quot;#ctl00_cphMainContentPage_rgThirdPartyCommissions_ctl00_ctl07_rdtbTPCCommissionAmount&quot;).val = calculatedAmount;
           commissionAmt._value = calculatedAmount.toFixed(2);
           commissionAmt._text = calculatedAmount.toFixed(2);
           commissionAmt.value = calculatedAmount
}</pre>

I have used all diffrent property/methods to set the value some of them are setting the value on UI but when i tried to DirectCast this control on serverside it gives me it's old value not the updated which i set from Javascript just like above.

<pre lang="sql">commissionAmt = DirectCast(editedItem.FindControl(&quot;rdtbTPCCommissionAmount&quot;), RadNumericTextBox).Text
</pre>

So suggestion will be welcome to to fix this issue?

3 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 26 Dec 2013, 07:56 AM
Hi Himanshu,

Please try the following approach to access a one RadNumericTextBox from other on its onblur event:

ASPX:
<telerik:GridTemplateColumn HeaderText="Coulmn1">
    <EditItemTemplate>
        <telerik:RadNumericTextBox ID="RadNumericTextBox1" runat="server">
        </telerik:RadNumericTextBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText="Coulmn2">
    <EditItemTemplate>
        <telerik:RadNumericTextBox ID="RadNumericTextBox2" runat="server">
        </telerik:RadNumericTextBox>
    </EditItemTemplate>
</telerik:GridTemplateColumn>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = (GridEditableItem)e.Item;
        RadNumericTextBox textbox1 = item.FindControl("RadNumericTextBox1") as RadNumericTextBox;
        RadNumericTextBox textbox2 = item.FindControl("RadNumericTextBox2") as RadNumericTextBox;
        textbox2.Attributes.Add("onBlur", "return Onblur('" + textbox1.ClientID + "','" + textbox2.ClientID + "')");      
    }
}

JS:
<script type="text/javascript">
    function Onblur(txt1, txt2) {
        var text1 = $find(txt1);// Access 1st textbox
        var text2 = $find(txt2);//Access 2nd textbox
        var total = text2.get_textBoxValue();
        text1.set_value(total); //set value to 1st textbox
    }
</script>

Thanks,
Princy
0
Himanshu
Top achievements
Rank 1
answered on 27 Dec 2013, 06:25 AM
Thanks a lot Princy. That's perfectly worked. :) But i don't understand it's weird behaviour in my scenario. Do you have any thoughts on it?
0
Princy
Top achievements
Rank 2
answered on 27 Dec 2013, 08:49 AM
Hi Himanshu,

From your code I'm not sure how you are trying to access the RadNumericTextBox. Setting the RadTextBox value using its set_value() client method should persist it after subsequent submits.

Thanks,
Princy

Tags
Grid
Asked by
Himanshu
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Himanshu
Top achievements
Rank 1
Share this question
or