4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 26 Oct 2012, 04:42 AM
Hi,
Please try the following code snippet to select a row on TextBox click.
ASPX:
C#:
Javascript:
Thanks,
Princy.
Please try the following code snippet to select a row on TextBox click.
ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </ItemTemplate> </telerik:GridTemplateColumn>C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e){ if (e.Item is GridDataItem) { GridDataItem item = (GridDataItem)e.Item; int index = item.ItemIndex; TextBox txtbx = (TextBox)item["TempCol"].FindControl("TextBox1"); txtbx.Attributes.Add("OnClick", "return Select('" + index + "');"); } }Javascript:
<script type="text/ecmascript">function Select(index){ var grid = $find("<%= RadGrid1.ClientID %>"); grid.MasterTableView.get_dataItems()[index].set_selected(true); } </script>Thanks,
Princy.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 26 Oct 2012, 05:10 AM
Hello,
By mistake Princy forget to add C# code.
So please try with updated code.
Thanks,
Jayesh Goyani
By mistake Princy forget to add C# code.
So please try with updated code.
<telerik:GridTemplateColumn> <ItemTemplate> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </ItemTemplate></telerik:GridTemplateColumn> protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { TextBox TextBox1 = e.Item.FindControl("TextBox1") as TextBox; TextBox1.Attributes.Add("onclick", "Select('"+e.Item.ItemIndex+"');"); }}function Select(index) { var grid = $find("<%= RadGrid1.ClientID %>"); grid.MasterTableView.get_dataItems()[index].set_selected(true); }Thanks,
Jayesh Goyani
0
Ankush
Top achievements
Rank 1
answered on 06 Dec 2014, 07:44 PM
Hi Jayesh/Princy/All,
I am facing an issue. Row is getting highlighted when I click on the text in the row but when I click on the empty space in the row, row is not getting highlighted.
It seems no event is firing on clicking on empty space in the row(screenshot attached). Please help !
Thanks,
Ankush
I am facing an issue. Row is getting highlighted when I click on the text in the row but when I click on the empty space in the row, row is not getting highlighted.
It seems no event is firing on clicking on empty space in the row(screenshot attached). Please help !
Thanks,
Ankush
0
Hi Ankush,
Can you please elaborate on your specific configuration? The rows should be selected as expected on cell click:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/row-selection/defaultcs.aspx
Regards,
Eyup
Telerik
Can you please elaborate on your specific configuration? The rows should be selected as expected on cell click:
http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/selecting/row-selection/defaultcs.aspx
Regards,
Eyup
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.
