We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Hyperlink

Thread ID:

Created:

Updated:

Platform:

Replies:

128087 Jan 1,2017 10:46 PM UTC Jan 4,2017 06:09 AM UTC ASP.NET MVC 5
loading
Tags: Grid
Bernard Jurlina
Asked On January 1, 2017 10:46 PM UTC

How can I create hyperlink in a column with col.Field value as text? 
What I want to get is to click on the name of the employee in the grid to get it's details.

Thanks,
and best wishes for the New Year.

Saravanan Arunachalam [Syncfusion]
Replied On January 2, 2017 06:44 AM UTC

Hi Bernard, 
Thanks for contacting Syncfusion’s support. 
Query 1: How can I create hyperlink in a column with col.Field value as text? 
We have already discussed this query in the following Knowledge Base document. 
Query 2: What I want to get is to click on the name of the employee in the grid to get it's details. 
We have achieved your requirement by using “RecordClick” event of Grid control and refer to the below code example.  
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.datasource) 
        
        .ClientSideEvents(eve => eve.RecordClick("recordclick")) 
        .Columns(col => 
        { 
            col.Field("EmployeeID").HeaderText("Employee ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); 
            col.Field("EmployeeName").HeaderText("Name").Width(100).Add(); 
            col.Field("City").Width(100).Add(); 
             
        }) 
) 
<script> 
    function recordclick(args) { 
        //Get the details of the row when click the name of the employee 
        if ($(args.cell).index() == 1) { 
            alert("Employee ID:" + args.data.EmployeeID + "\nName:" + args.data.EmployeeName + "\nCity:" + args.data.City); 
        } 
    } 
</script> 
 
Regards, 
Saravanan A. 


Bernard Jurlina
Replied On January 2, 2017 10:18 PM UTC

Hi Saravanan,

thanks for answering my questions. You gave me the link to Knowledge Base for creating a hyperlink in a column. I saw that before, but, If you look at the picture of grid in that example, column "Manage records" has fixed text "View", which is text for the hyperlink. 
col.HeaderText("Manage Records").Template(" <a rel='nofollow' href='#''>View</a>").Add();
I do not want to have fixed text for that, I want values from column OrderID, for example, as text for the hyperlink. So, how can I replace "View" in template with cell value?

Thank You.
Bernard.



Saravanan Arunachalam [Syncfusion]
Replied On January 3, 2017 09:03 AM UTC

Hi Bernard, 
By default Grid uses JsRender template and we can achieve your requirement with the below code example. 
@(Html.EJ().Grid<object>("FlatGrid") 
          . . . 
        .Columns(col => 
        { 
            . . . 
            col.HeaderText("Manage Records").Template("<a rel='nofollow' href='#''>{{:OrderID}}</a>").Add(); 
             
        }) 
) 
 
Regards, 
Saravanan A. 


Bernard Jurlina
Replied On January 3, 2017 10:24 PM UTC

Excellent, it works like a charm.

Thank You once again!

Bernard.

Pavithra Subramaniyam [Syncfusion]
Replied On January 4, 2017 06:09 AM UTC

Hi Bernard,
Thanks for your update.          
We are happy that the provided information helped you.
Regards,
Pavithra S.
​​​

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;