This is a migrated thread and some comments may be shown as answers.

[Solved] How to disable the link in a GridHyperLinkColumn clientside

1 Answer 441 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Luke
Top achievements
Rank 1
Luke asked on 27 Jul 2009, 10:53 AM
I have a grid which includes a GridHyperLinkColumn.  The enabled state of the link needs to be set dynamically based on values in other columns in the grid.  This needs to be done client-side (as I'm building an MVC app).

I've added a RowDataBound event handler:
function RadIncidents_RowDataBound(sender, args)
{
        var cell = args.get_item().get_cell("colActionText");
        if (cell)
        {
            if (dataItem.CanQuickReview)
            {
                cell.disabled = false;
                cell.title = "Click to quick-review this item.";
            }
            else
            {
                cell.disabled = true;
                cell.title = "This item cannot be quick-reviewed.";
            }
        }
    }
}

This makes the link look disabled (its colour is changed), but it still functions as an active, enabled link.
I've also tried replacing the cell's inner Html with its text, but this then gets cached across grid refresh / rebinds.

Does anyone know how to properly disable the link in a GridHyperLinkColumn?
Thanks,
Luke.

1 Answer, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jul 2009, 10:45 AM
Hi Luke,

You can disable a hyperlink column in the RowDataBound event (given that the hyperlink column is only one) as follows:

                args.get_item().get_element().getElementsByTagName("a").item().disabled = true;  
                args.get_item().get_element().getElementsByTagName("a").item().removeAttribute("href");     

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Luke
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Share this question
or