Hi all,
could please somebody help me with this problem?
I have RadNumericTextBox in GridTemplateColumn of RadGrid. I want two things:
- OnKeyPress it will compute differnce between its value and some start value
- OnValueChanged it will update value in database (through AJAX call)
ASPX page snippet:
Snippet of code-behind:
Snippet of javascript:
Thank you very much for your help!
could please somebody help me with this problem?
I have RadNumericTextBox in GridTemplateColumn of RadGrid. I want two things:
- OnKeyPress it will compute differnce between its value and some start value
- OnValueChanged it will update value in database (through AJAX call)
ASPX page snippet:
<
telerik:GridTemplateColumn
UniqueName
=
"colValue"
HeaderText
=
"Stav"
ItemStyle-Width
=
"35px"
>
<
ItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"txtCounterValue"
runat
=
"server"
Width
=
"80"
MinValue
=
"0"
NumberFormat-AllowRounding
=
"false"
NumberFormat-DecimalDigits
=
"0"
EnabledStyle-HorizontalAlign
=
"Right"
EnabledStyle-Font-Bold
=
"true"
>
<
ClientEvents
OnKeyPress
=
"CounterKeyPress"
OnValueChanged
=
"CounterValueChanged"
/>
</
telerik:RadNumericTextBox
>
<
div
id
=
"txtStartValue"
runat
=
"server"
></
div
>
<div
id
=
"txtDifference"
runat
=
"server"
></
div
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
Snippet of code-behind:
Protected
Sub
rgDeviceCountersDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Dim
myCounter =
DirectCast
(e.Item.DataItem, Data.DeviceCounter)
Dim
txtCounterValue
As
RadNumericTextBox =
DirectCast
(e.Item.FindControl(
"txtCounterValue"
), RadNumericTextBox)
txtCounterValue
=myCounter.StartValue
Dim
txtStartValue
As
HtmlGenericControl =
DirectCast
(e.Item.FindControl(
"txtStartValue"
), HtmlGenericControl)
txtDtartValue.InnerText=myCounter.StartValue
Dim
txtDifference
As
HtmlGenericControl =
DirectCast
(e.Item.FindControl(
"txtDifference"
), HtmlGenericControl)
End
Sub
Snippet of javascript:
var
ajaxManager;
function
pageLoad() {
ajaxManager = $find(
"<%=RadAjaxManager.GetCurrent(Page).ClientID %>"
);
}
function
CounterKeyPress(sender, eventArgs) {
/* update InnerText of txtDifference
with difference between RadNumericTextBox andtxtStartValue
*/
/* HOW TO ACHIEVE THIS? :-) */
}
function
CounterValueChanged
(sender, eventArgs) {
/* Count difference betweentxtStartValue
and txtCounterValue
and call AJAX update of record (how to get Primary Id from ClientDataKeyNames?) */
ajaxManager
.ajaxRequest(... AND WHAT HERE ...?);
}
Thank you very much for your help!