Reputation: 20468
How Can I Retrieve SelectedID of Telerik RadGrid On Client-Side Without Using OnRowSelected event?
so lets to see my scenarion:
my grid properties are like this :
<telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" DataSourceID="SqlDataSource1" AllowPaging="True" AutoGenerateColumns="False" CellSpacing="0"
Width="660px" onitemdatabound="RadGrid1_ItemDataBound">
<ClientSettings Selecting-AllowRowSelect="true">
<Selecting AllowRowSelect="True"></Selecting>
<ClientEvents OnRowSelected="OnRowSelected" />
</ClientSettings>
...
and goal Column :
<telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn_Q column"
HeaderText="Q" UniqueName="TemplateColumn_Q">
<ItemTemplate>
<asp:Label ID="lblQInsideGrd" runat="server" Font-Size="11px" Text='<%# GetQ(Eval("Q")) %>'></asp:Label>
</ItemTemplate>
</telerik:GridTemplateColumn>
i fill this column in code behind like this :
protected string GetQ(object Q)
{
if (Q.ToString().Length < 10)
{
return Q.ToString();
}
else
{
string Q_str = Q.ToString();
Q_str = Q_str.Substring(0, 10) + "<span style='font-size:9px;color:red;'><a href='#' class='QClick'> (Full View...)</a></span>";
return Q_str;
}
as you see there is an anchor in every column that i want to retrieve related ID filed of that anchor in client side and show that id in an alert.
for server-side we can use CommandName property for that anchor.
also for client-side when we click on every row we can use OnRowSelected event to retrieve that id.
but in my situation, clicking on those anchors will not couse to select the entire row for firing OnRowSelected.
so what can i do about that?
thanks in advance
Upvotes: 0
Views: 3133
Reputation: 236
var radGrid = $find('<%= RadGrid1.ClientID %>');
var selectedItems = radGrid.get_masterTableView().get_selectedItems()
...
Here you are :)
Upvotes: 3