我有一個Telerik的radgrid控件,如所示下面Telerik的文本選擇
| Username | Password |
-------------------------
| A_user | ***** |
| A_user2 | ***** |
| A_user3 | ***** |
當我點擊行之一,它會顯示點擊行的密碼,就像這樣:
| Username | Password |
-------------------------
| A_user | ***** |
| A_user2 | A password |
| A_user3 | ***** |
這工作正常。我正在繼續這種方式,因爲密碼的解密是一個相當複雜和漫長的過程,因此一次解密一個密碼不會耗費時間,特別是當用戶不需要所有密碼時。
當我顯示密碼時,我希望能夠在網格中選擇密碼來複制它。不幸的是,radgrid會再次激發「RowClick」itemcommand,並且該行被取消選中。因此,我無法複製密碼。
我的問題是:有沒有辦法在某些情況下取消radgrid的itemcommand? 我希望能夠在密碼已解密時禁用itemcommand事件。
在此先感謝!
編輯: 我想我也應該提的是,我使用的是radajaxloadingpanel顯示在網格的動畫時,它的加載。即使itemcommand方法不執行任何操作,也會顯示ajaxloadingpanel,並且我嘗試突出顯示的文本被取消選定。
更多編輯:
這裏是我的radgrid控件的代碼
<telerik:RadGrid id="radGridAccounts" runat="server" Width="99%" PageSize="20" AllowPaging="true" AllowSorting="true"
AllowFilteringByColumn="True" ShowStatusBar="true" EnableLinqExpressions="False" GridLines="None"
AllowMultiRowSelection="false">
<ClientSettings EnableRowHoverStyle="true" EnablePostBackOnRowClick="true" AllowKeyboardNavigation="false">
<Selecting AllowRowSelect="True" />
<KeyboardNavigationSettings EnableKeyboardShortcuts="false" />
</ClientSettings>
<PagerStyle Mode="NextPrevAndNumeric" PagerTextFormat=""/>
<MasterTableView AutoGenerateColumns="False" EditMode="InPlace" CommandItemDisplay="Top"
InsertItemDisplay="Top" AllowFilteringByColumn="True" NoMasterRecordsText="Aucun compte"
InsertItemPageIndexAction="ShowItemOnCurrentPage" DataKeyNames="USERN" >
<Columns>
<%--Username--%>
<telerik:GridBoundColumn UniqueName="USERN" DataField="USERN" HeaderText="Username"
AllowFiltering="true" ColumnEditorID="radUsernameEditor"/>
<%--Password--%>
<telerik:GridBoundColumn UniqueName="PASWR" DataField="PASWR" HeaderText="Password"
AllowFiltering="false" ColumnEditorID="radPasswordEditor" />
<%--Edit--%>
<telerik:GridEditCommandColumn ButtonType="ImageButton"
InsertImageUrl=".\Images\ok.gif" UpdateImageUrl=".\Images\ok.gif" CancelImageUrl=".\Images\cancel.gif" />
<%--Delete--%>
<telerik:GridButtonColumn ButtonType="ImageButton" CommandName="Delete" Text="Delete"
ImageUrl=".\Images\delete.gif" />
</Columns>
<CommandItemSettings AddNewRecordText="" RefreshText="" />
</MasterTableView>
</telerik:RadGrid>
我的ItemCommand代碼:
Protected Sub radGridAccounts_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles radGridAccounts.ItemCommand
Try
If (e.CommandName = "RowClick" AndAlso TypeOf e.Item Is GridDataItem) Then
e.Item.Selected = True
For Each item As GridDataItem In radGridAccounts.Items
If Not item.IsInEditMode Then
If item.Selected Then
'Decrypt the password method
Else
item.Cells(4).Text = "*****"
End If
End If
Next
End If
Catch ex As Exception
DisplayMessage("Error : " & ex.Message, MessageType.Err)
End Try
End Sub
可以只張貼您的radgrid控件的代碼,只是有興趣在你使用 – 2012-03-23 14:44:32
謝謝你看進我的問題命令。我已經添加了代碼。 – Msonic 2012-03-23 14:57:51