
Iosu Buenetxea
Top achievements
Rank 1
Iosu Buenetxea
asked on 18 Sep 2008, 04:35 PM
Hello
I'm using some templates in my radGrid, in this templates I have a Textbox inside, when I click in the row I throw the SelectedIndexChanged method, but when I click in the textbox I want to select this row and throw the selectedIndexChanged method also.
How can I do this?
Thanks.
I'm using some templates in my radGrid, in this templates I have a Textbox inside, when I click in the row I throw the SelectedIndexChanged method, but when I click in the textbox I want to select this row and throw the selectedIndexChanged method also.
How can I do this?
Thanks.
4 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 19 Sep 2008, 06:52 AM
Hi Juan,
Try the following code snippet to achieve the desired scenario.
ASPX:
CS:
JS:
Cheers
Shinu.
Try the following code snippet to achieve the desired scenario.
ASPX:
<telerik:GridTemplateColumn UniqueName="TempCol" HeaderText="TempCol" > |
<ItemTemplate> |
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> |
</ItemTemplate> |
</telerik:GridTemplateColumn> |
CS:
protected void RadGrid1_ItemDataBound(object sender, 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 + "');"); |
} |
} |
JS:
<script language="javascript" type="text/javascript"> |
function Select(index) |
{ |
var grid = $find("<%= RadGrid1.ClientID %>"); |
grid.MasterTableView.get_dataItems()[index].set_selected(true); |
__doPostBack("<%=RadGrid1.ClientID %>") |
} |
<script /> |
Cheers
Shinu.
0

Iosu Buenetxea
Top achievements
Rank 1
answered on 19 Sep 2008, 07:42 AM
Hello Shinu !!
This is a solution but when I select another row the radGrid has selected more than one row, and I want to have only one row selected.
How can I do this?
This is a solution but when I select another row the radGrid has selected more than one row, and I want to have only one row selected.
How can I do this?
0
Accepted

Princy
Top achievements
Rank 2
answered on 19 Sep 2008, 09:01 AM
Hi Juan,
One suggestion will be to clear the all the selected items in the client event before selecting the row.
JS:
Hope this helps..
Princy.
One suggestion will be to clear the all the selected items in the client event before selecting the row.
JS:
<script language="javascript" type="text/javascript"> |
function Select(index) |
{ |
var grid = $find("<%= RadGrid1.ClientID %>"); |
grid.get_masterTableView().clearSelectedItems(); |
grid.MasterTableView.get_dataItems()[index].set_selected(true); |
} |
<Script/> |
Hope this helps..
Princy.
0

Iosu Buenetxea
Top achievements
Rank 1
answered on 19 Sep 2008, 01:56 PM
Hello Princy
This is the answer, Thanks.
This is the answer, Thanks.