我有一个radgrid
填充了双击数据我启动了一个带有texbox
的rad窗口管理器,需要填写radgrid
上选择的数据。我没有得到行的值。我只能获得所选项目的索引。
这是我的网格aspx:
<telerik:RadGrid ID="rgBuscar" runat="server" CellSpacing="0" Culture="es-ES"
GridLines="None" Height="469px" Skin="Hay" Width="944px">
<ClientSettings>
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
</MasterTableView>
<ClientSettings>
<Selecting AllowRowSelect="True" />
<ClientEvents OnRowDblClick="RowDblClick"/>
</ClientSettings>
<PagerStyle PageSizeControlType="RadComboBox"></PagerStyle>
<FilterMenu EnableImageSprites="False"></FilterMenu>
和我的JS:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function RowDblClick(sender, args) {
var index = args.get_itemIndexHierarchical();
sender.get_masterTableView().fireCommand("RowDblClick", index);
}
</script>
最后我的VB:
Protected Sub rgBuscar_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgBuscar.ItemCommand
If e.CommandName = "RowDblClick" Then
Dim var As String = e.CommandArgument
idValor = e.Item.Cells(2).Text
MostrarVentana(idValor)
End If
End Sub
Public Sub MostrarVentana(ByVal IdCampo As Integer)
lector = objBd.obtenerConfiguraciones("Cambio Ordenes")
While lector.Read
rwmCambio.Windows(0).NavigateUrl = lector("OCON_Url") & "?IdCampo=" & IdCampo
rwmCambio.Windows(0).Width = Unit.Pixel(lector("OCON_Width"))
rwmCambio.Windows(0).Height = Unit.Pixel(lector("OCON_Height"))
End While
rwmCambio.Windows(0).VisibleOnPageLoad = True
End Sub
答案 0 :(得分:2)
Telerik为RadGrid
提供了丰富的API,为DataKeyValues
指定了一个值(如果您想使用客户端API访问它们而不是回发,则为ClientDataKeyNames
)属性MasterTableView
您可以通过代码访问与项目相关的数据;要向数据键集合添加多个列,请使用逗号分隔列名称。
示例数据键定义:
<MasterTableView DataKeyNames="idColumnName,foreignKeyColumnName" ClientDataKeyNames="idColumnName,anotherColumnName">
示例OnRowSelected
事件客户端(JavaScript)事件处理程序:
function OnGridRowSelected(sender, args) {
var idDataKey = args.getDataKeyValue("idColumnName");
var nameDataKey = args.getDataKeyValue("idColumnName");
document.getElementById("myElement").value = "(" + idDataKey + ") " + nameDataKey;
}
示例ItemCommand
事件服务器端(VB)事件处理程序:
Protected Sub PerformActionOnGridItem(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles grdCustomerAccountInvoiceSummary.ItemCommand
If (TypeOf (e.Item) Is Telerik.Web.UI.GridDataItem) Then
Dim item As Telerik.Web.UI.GridDataItem = CType(e.Item, Telerik.Web.UI.GridDataItem)
Select Case e.CommandName
Case "RowDblClick"
' Insert required code here
...
' Example: Set session variable to data key value
Session("idColumnName") = item.GetDataKeyValue("idColumnName")
End Select
End If
End Sub