Hyperlink based on another cell

Hi there,

I am trying to add a column/cell at the end of the grid columns to provide a hyperlink based on let's say ID of the record (e.g "<a rel='nofollow' href='/Project?ProjectID=1'>Details</a>")

I have seen few posts regarding links within Grid, but unable to put something together, any assistance on this would be highly appreciated.

I am using MVC 5 / syncfusion version 13.3.0.7

Regards
Prasanthan

3 Replies

AS Alan Sangeeth S Syncfusion Team October 26, 2015 05:28 AM UTC

Hi Prasanthan,

Thanks for using Syncfusion products.


We can place Hyperlink in a Grid column using the Column template feature of the grid. The template to a particular column can be provided by using Template and TemplateID properties of the column. Please refer the following code snippets.

@(Html.EJ().Grid<object>("ColumnTemplate")


.Columns(col =>

        {

col.Field("OrderID").HeaderText("Order ID").Width(90).Add();

             

col.HeaderText("Employee HyperLink").Template(true).TemplateID("#columnTemplate")       .TextAlign(TextAlign.Center).Width(110).Add();

           

        })

)


<script type="text/x-jsrender" id="columnTemplate">

  @*In the template column we can get the values of corresponding row.*@

    <a rel='nofollow' href='/Project/?Id={{:OrderID}}'> Details</a>

</script>



For your convenience we have created a sample that can be downloadable from the following link.

Sample: http://www.syncfusion.com/downloads/support/forum/120871/ze/EJGrid295300443

Regards,
Alan Sangeeth S


PR Prasanth October 26, 2015 06:48 AM UTC

Hi Alan

Thanks for that :-) will try it and if there are any issues will post a message

Regards
Prasanthan


SA Saravanan Arunachalam Syncfusion Team October 27, 2015 04:09 AM UTC

Hi Prasanthan,

Thanks for your update.          

We will wait to hear from you.

Regards,

Saravanan A.


Loader.
Up arrow icon