Radgrid have item template columns using RadNumeric TextBox ,CheckBox . I am using "OnKeypress" function in java Script when i press key check box checked ,otherwise unchecked, and i using (delete,backspace,Alt+A) to remove the data in text box on that time unchecked the check box
pleas solve me this problem
pleas solve me this problem
4 Answers, 1 is accepted
0
Hello,
If you need to handle the delete or the backspace keys you will need to attach handler for the onkeydown event and not for the OnKeyPress event of the RadNumericTextBox.
As for getting reference to the checkbox, you could use the $telerik.findElement(container, id) method, where the container will be the TD element of the cell.
For your convenience, following is a simple example with the requirement that you have:
Hope this help.
Regards,
Konstantin Dikov
Telerik
If you need to handle the delete or the backspace keys you will need to attach handler for the onkeydown event and not for the OnKeyPress event of the RadNumericTextBox.
As for getting reference to the checkbox, you could use the $telerik.findElement(container, id) method, where the container will be the TD element of the cell.
For your convenience, following is a simple example with the requirement that you have:
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function keyDown(element, ev) {
var cell = Telerik.Web.UI.Grid.GetFirstParentByTagName(element, "TD")
var checkBox = $telerik.findElement(cell, "CheckBox1");
setTimeout(function () {
var value = element.value;
console.log(value);
if (value != "") {
checkBox.checked = true;
}
else {
checkBox.checked = false;
}
})
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
>
<
Columns
>
<
telerik:GridTemplateColumn
>
<
ItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox1"
runat
=
"server"
onkeydown
=
"keyDown(this, event)"
></
telerik:RadNumericTextBox
>
<
asp:CheckBox
runat
=
"server"
ID
=
"CheckBox1"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Hope this help.
Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
0

NA
Top achievements
Rank 1
answered on 24 Mar 2015, 05:45 AM
Hi Konstantin Dikov,
Thanks for reply
The above code is working but, my scenario RadNumericTextBox ,check box are two separate Item templates in this case your suggested code is not working give any suggestions.
Thanks for reply
The above code is working but, my scenario RadNumericTextBox ,check box are two separate Item templates in this case your suggested code is not working give any suggestions.
0
Accepted
Hello,
The only change that you need to make in the JavaScript logic for handling a scenario where the controls are in separate columns is to call the GetFirstParentByTagName method to find the "TR" element, which will be the TR element corresponding to the data item:
Hope this helps.
Regards,
Konstantin Dikov
Telerik
The only change that you need to make in the JavaScript logic for handling a scenario where the controls are in separate columns is to call the GetFirstParentByTagName method to find the "TR" element, which will be the TR element corresponding to the data item:
<
telerik:RadCodeBlock
ID
=
"RadCodeBlock1"
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
function keyDown(element, ev) {
var row = Telerik.Web.UI.Grid.GetFirstParentByTagName(element, "TR")
var checkBox = $telerik.findElement(row, "CheckBox1");
setTimeout(function () {
var value = element.value;
console.log(value);
if (value != "") {
checkBox.checked = true;
}
else {
checkBox.checked = false;
}
})
}
</
script
>
</
telerik:RadCodeBlock
>
<
telerik:RadGrid
runat
=
"server"
ID
=
"RadGrid1"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
AutoGenerateColumns
=
"false"
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"NumericColumn"
>
<
ItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox1"
runat
=
"server"
onkeydown
=
"keyDown(this, event)"
></
telerik:RadNumericTextBox
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CheckBoxColumn"
>
<
ItemTemplate
>
<
asp:CheckBox
runat
=
"server"
ID
=
"CheckBox1"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Hope this helps.
Regards,
Konstantin Dikov
Telerik
See What's Next in App Development. Register for TelerikNEXT.
0

NA
Top achievements
Rank 1
answered on 26 Mar 2015, 12:34 PM
Hi Konstantin Dikov,
Thank you for reply
Your suggested sample code working Thank You
Thank you for reply
Your suggested sample code working Thank You