0
我正在使用Telerik的ASP.NET AJAX庫,並且我爲RadGrid中的每一行都有一個RadRating元素,並且需要獲取RadRating所在行的關聯Id被評爲(但帶有Javascript),但是,get_parent()
方法正在返回網格引用而不是行。從JavaScript獲取RadGrid RadRrid的關聯Id
如何獲得RadRating行的GridDataItem
?
下面的代碼有時候並不是所有的時候都有效。我究竟做錯了什麼?
<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>
哪裏是'get_parent()'的聲明? –
@AndrueAnderson get_parent()是Javascript中的RadRating對象的一種方法。事實上,Rad控件中的每個控件都可以使用 –
我向你保證JavaScript中沒有RadRating對象,也許你是指一些框架或API? –