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. Image for the cookie policy date
close icon

Column template redirect route type Html.ActionLink

Hello,

it is possible to add de column templante html.actionlink?

  @(Html.EJ().Grid<Mobile.B2B.Domain.Models.Product>("FlatGrid")
         .Datasource((IEnumerable<object>)Model.List)
                                     .AllowSorting()
                                     .AllowPaging()                                 
                                     .Columns(col =>
                                     {
                                         col.Field("ProductId").HeaderText("Id").Width(90).Add();
 columns.Template("").ClientTemplate("" + @Html.ActionLink("Details", "Details", "Products", new { productId= "{ProductId}" }, new { @class = "btn" }) + "").Width(70);
      })
    )

thanks
Carlos


5 Replies

AR Ajith R Syncfusion Team April 28, 2015 11:59 AM UTC

Hi Carlos,

Thanks for using Syncfusion products.

Query: It is possible to add de column templante html.actionlink?

We would like to let you know that, it is not possible to render the jsrender templates by using Html.ActionLink reouteValues due to its server side object values. We suggest you to use html anchor tags instead of Html.ActionLink to resolve the issue. Please refer the below code snippet for further details.

[CSHTML]

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

<a rel='nofollow' href="CustomerDetails?OrderID={{:OrderID}}">{{:CustomerID}}</a>

</script>


@(Html.EJ().Grid<GridActionLink.OrdersView>("FlatGrid")

.Columns(col =>

{

col.HeaderText("Customer ID").Template("#customerTemplate").Width(80).Add();


})

)
[CS]

public ActionResult CustomerDetails(long OrderID)

{

//Write your code here

return View();
}


Note: We have analyzed your code snippet and found that you have used ClientTemplate in Grid column properties. For your kind information there is no such property under columns in the Grid.

For your convenience we have created a simple sample and the same can be downloaded from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/118954/Sample2064567500.zip

Please let us know if you have any concerns.

Regards,
Ajith R


CS Carlos Sousa replied to Ajith R May 1, 2015 04:11 AM UTC

Hi Carlos,

Thanks for using Syncfusion products.

Query: It is possible to add de column templante html.actionlink?

We would like to let you know that, it is not possible to render the jsrender templates by using Html.ActionLink reouteValues due to its server side object values. We suggest you to use html anchor tags instead of Html.ActionLink to resolve the issue. Please refer the below code snippet for further details.

[CSHTML]

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

<a rel='nofollow' href="CustomerDetails?OrderID={{:OrderID}}">{{:CustomerID}}</a>

</script>


@(Html.EJ().Grid<GridActionLink.OrdersView>("FlatGrid")

.Columns(col =>

{

col.HeaderText("Customer ID").Template("#customerTemplate").Width(80).Add();


})

)
[CS]

public ActionResult CustomerDetails(long OrderID)

{

//Write your code here

return View();
}


Note: We have analyzed your code snippet and found that you have used ClientTemplate in Grid column properties. For your kind information there is no such property under columns in the Grid.

For your convenience we have created a simple sample and the same can be downloaded from the below link.

Sample Link: http://www.syncfusion.com/downloads/support/forum/118954/Sample2064567500.zip

Please let us know if you have any concerns.

Regards,
Ajith R

Ajith, thank you for your answer, good help

Regards.
Carlos


AR Ajith R Syncfusion Team May 4, 2015 08:58 AM UTC

Hi Carlos,

Thanks for your update.

We are happy to hear that your requirement has been achieved in your end.

Please get back to us if you have any other concerns.

Regards,
Ajith R


JP Jayakumar Paramasivam October 17, 2017 02:44 AM UTC

Hi Support,

I am using custom action link method to encrypt all my route values. 

If I use HTML anchor tag means, how to encrypt my route values.

Can you give me the solution to encrypt route values 





SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team October 17, 2017 11:54 AM UTC

Hi JayaKumar,  
 
We can add anchor element in the following two ways to the template column.  
 
In the first method, we can add the anchor element directly to the Column.Template as shown in the following code example. 
 
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.dataSource) 
        .AllowPaging() 
              . . . 
                .Columns(col => 
            { 
                . . . 
                col.Field("Freight") 
                    .HeaderText("Freight") 
                    .Template("<a class='clas' rel='nofollow' href='/Home/Index.cshtml?ID={{:Freight}}'>{{:Freight}}</a>").Add(); 
            }) 
) 
 
In the second method, we can use the templateRefresh event, where we can assign a value to the anchor element bound with the column template.  
 
@(Html.EJ().Grid<object>("FlatGrid") 
        .Datasource((IEnumerable<object>)ViewBag.dataSource) 
        .AllowPaging() 
               
                .Columns(col => 
            { 
                 
                col.HeaderText("Edit") 
                    .Template("<a>Click Me</a>").Add(); 
            }) 
                .ClientSideEvents(e => e.TemplateRefresh("templateRefresh")) 
) 
 
<script> 
 
    function templateRefresh(args) { 
        $(args.cell).find("a").attr("rel='nofollow' href","/Home/Index?ID="+args.data.OrderID+"") 
    } 
 
</script> 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Live Chat Icon For mobile
Up arrow icon