Ticket T527956
Visible to All Users

Grid - How to activate a read-only HyperLink

created 8 years ago

[FROM How to make a read-only Hyper link column launch a web browser when a link is clicked]

Do you know if the article is relevant at the moment?
And is this the only way to open a link if the view is not in edit mode?

Answers approved by DevExpress Support

created 8 years ago

Hello Andrey,
Yes, this article is relevant.
Another option to open a link without additional actions is to set the ColumnViewOptionsBehavior.ReadOnlyproperty to "true". In read-only mode, cell editors can be invoked. However, end-users can only select and copy an editor's content. Note: if you want to open the link with a single click, make sure that the RepositoryItemHyperLinkEdit.SingleClick property is enabled.
I hope this information will be helpful to you. If you have additional questions, just let us know.

    Other Answers

    created 4 years ago (modified 4 years ago)

    I know this is an old post, but I had difficulty getting readonly hyperlinks (in my case for email) to work. The issue turned out to be the fact that I had set the view's OptionsSelection.EnableAppearanceFocusedCell to False. Even with everything else, the _OpenLink event would not fire unless this setting was set to True.

    Here are the steps I performed to get the hyperlink to work with a single click of the cell in a gridview meant to be readonly.

    1. Add hyperlinkedit editor to the column and set SingleClick to true
    2. Add the _OpenLink event to the code behind and insert logic to process hyperlink. (This works for email addresses)
    C#
    if (e.EditValue == null) return; if (!string.IsNullOrWhiteSpace(e.EditValue.ToString())) { string prefix = "mailto:"; if (!e.EditValue.ToString().ToLower().StartsWith(prefix)) { e.EditValue = prefix + e.EditValue.ToString(); } }
    1. Set all other columns' OptionsColumn.AllowEdit = False except for the email column which remains True
    2. Set view OptionsBehavior.Editable = True
    3. Set view OptionsSelection.EnableAppearanceFocusedCell = True

    This will allow single-click processing of the hyperlink while maintaining a read-only status for everything else.

    I hope this is helpful.

      Comments (1)
      Sasha (DevExpress Support) 4 years ago

        Hi,

        Thank you for sharing your solution. I believe it may be helpful for other users.

        If you require any assistance, please let us know. We will be happy to be of help.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.