[RESOLVED]Proving link in telerik grid in mvc

I have a telerik grid and i need link in that grid.

the link will be enabled based on the condition 

ex : I have 3 columns in the grid.

if 1st column data is "completed successfully" then I need to enable the link for that row in 2nd column.

How to achieve this.

You’ll likely need to use the available ClientTemplate property for the Telerik Grid and use some type of property to check if your condition is met :

columns.Bound(p => p.YourProperty);
columns.Bound(p => p.YourOtherProperty).ClientTemplate("<#= (YourFirstProperty.Contains("success") ? <a href='#'>Your Link Here</a> : '' #>")

Thanks for the reply.

But my link is not some URL. I need to call a method in controller.

If my first property does not contain "successful", I need to disable the link.

How to do the enable and disable part in clienttemplate.

Is there any reason that you are attempting to perform this logic within your actual Grid? Wouldn’t it be more efficient to create a ViewModel to bind to your Grid and include the appropriate logic for what to output within the Grid in your model?

You can use TagBuilder to generate html anchor tag. You can also use a UrlHelper.


Leave a Reply