I have a RadRating element for each row in a RadGrid, and need to get the associated Id for the row where the RadRating is being Rated (but with Javascript), however, the get_parent() method is returning the grid reference and not the row.
How can I get the GridDataItem of the row of the RadRating?
The following code works sometimes but not all the time. What am I doing wrong?
<
script
type
=
"text/javascript"
>
(function(global,undefined) {
function OnClientRating(controlRating,args) {
var row = controlRating.get_parent();
var userId = row.getDataKeyValue("UserId");
}
global.OnClientRating = OnClientRating;
})(window);
</
script
>
<
rad:RadGrid
runat
=
"server"
ID
=
"gridUsers"
Skin
=
"Hay"
EnableAJAX
=
"False"
AutoGenerateColumns
=
"False"
GridLines
=
"Both"
Width
=
"100%"
AllowSorting
=
"True"
OnItemDataBound
=
"Grid_ItemDataBound"
>
<
MasterTableView
DataKeyNames
=
"UserId"
ClientDataKeyNames
=
"UserId"
>
<
Columns
>
<
rad:GridTemplateColumn
HeaderText
=
"Name"
HeaderStyle-Width
=
"180px"
ItemStyle-Width
=
"180px"
>
<
ItemTemplate
>
<%# Eval("FullName")%>
</
ItemTemplate
>
</
rad:GridTemplateColumn
>
<
rad:GridTemplateColumn
HeaderText
=
"Rating"
HeaderStyle-Width
=
"100px"
ItemStyle-Width
=
"100px"
>
<
ItemTemplate
>
<
rad:RadRating
ID
=
"ratAppraiserRating"
runat
=
"server"
ItemCount
=
"5"
Value='<%# Eval("AverageRating")%>'
SelectionMode="Continuous" Precision="Item" Orientation="Horizontal" OnClientRating="OnClientRating"
OnRate="RatRating_Rate" AutoPostBack="true" />
</
ItemTemplate
>
</
rad:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
Scrolling
UseStaticHeaders
=
"false"
ScrollHeight
=
"240px"
AllowScroll
=
"true"
/>
<
Selecting
AllowRowSelect
=
"false"
/>
<
ClientEvents
OnRowDblClick
=
"selectRow"
/>
</
ClientSettings
>
</
rad:RadGrid
>