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

Setting value in UC of radgrid

1 Answer 72 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 27 Dec 2010, 03:59 PM
I am having issues with updating the value of a control within the edittemplate of a radgrid control. 

Here is the layout of the javascript

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"
        <script type="text/javascript">
            function setTotal() {
                var radCostF = 0;
                var radPercentF = 0;
                var radTotal;
                  
                var radLength = document.getElementsByTagName("INPUT");
                var strToFind = "TEMPCOST";
                for (i = 0; i < radLength.length; i++) {
                    var element = radLength[i];
                    strToFind = "TEMPCOST";
                    if (element.id.indexOf(strToFind) >= 0) {
                        if (element.id.lastIndexOf(strToFind) + strToFind.length == element.id.length) {
                            alert(element.id + "=" + element.value);
                            radCostF = element.value;
                        }
                    }
                    strToFind = "TEMPPCT";
                    if (element.id.indexOf(strToFind) >= 0) {
                        if (element.id.lastIndexOf(strToFind) + strToFind.length == element.id.length) {
                            alert(element.id + "=" + element.value);
                            radPercentF = element.value;
                        }
                    }
  
                    strToFind = "TOTAL";
                    if (element.id.indexOf(strToFind) >= 0) {
                         
                        if (element.id.lastIndexOf(strToFind) + strToFind.length == element.id.length) {
                        element.value = radCostF * radPercentF / 100;
                        }
                    }
  
  
                }
  
            }
          
        </script>
      
    </telerik:RadCodeBlock>


In the user control the code is such

 

<td>

 

Total:

<br />

 

 

<telerik:RadNumericTextBox NumberFormat-DecimalDigits="2" ID="TEMPCOST" runat="server"

 

 

Value= '<%#CheckNumericNull(DataBinder.Eval(Container, "DataItem.TEMPCOST"))%>' >

 

 

<ClientEvents OnBlur="setTotal" />

 

 

</telerik:RadNumericTextBox>

 

 

</td>

 

<

 

td>

 

 

 

 

Total:

<br />

 

 

 

 

 

<telerik:RadNumericTextBox NumberFormat-DecimalDigits="2" type="Currency" ID="TOTAL" runat="server"

 

 

 

 

 

ReadOnly="true" Value="0.00" />

 

 

 

 

 

</td>

 

 

 



The event OnBlur fires and I can read the values from the source controls and set the value of the target (TOTAL) but the value is not reflected to the user.  In other words if I set the value of TempCost to 100 and Percent to 10 then when I pass through the same code again, the value of the TOTAL field is 10 but screen still shows 0 even after the event has fired.  Any thoughts as to why the screen is not displaying the updated value?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 28 Dec 2010, 10:13 AM
Hello John,

Give a try with the following approach to access the RadNumericTextBox in user control edit form.

Java Script:
<script type="text/javascript">
    function setTotal() {
        var radCostF = $find("<%=TEMPCOST.ClientID %>").get_value(); // accessing value of RadNumericTextBox 'TEMPCOST'
        var radPercentF = $find("<%=TEMPPCT.ClientID %>").get_value(); accessing value of RadNumericTextBox 'TEMPPCT'
        $find("<%=TOTAL.ClientID %>").set_value(radCostF * radPercentF / 100) ;// seeting the reult to RadNumericTextBox 'TOTAL'
    }
</script>

Thanks,
Princy.
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or