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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Column template redirect route type Html.ActionLink

Thread ID:

Created:

Updated:

Platform:

Replies:

118954 Apr 27,2015 11:45 PM UTC Oct 17,2017 11:54 AM UTC ASP.NET MVC 5
loading
Tags: Grid
Carlos Sousa
Asked On April 27, 2015 11:45 PM UTC

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


Ajith R [Syncfusion]
Replied On 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

Carlos Sousa
Replied On 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

Ajith R [Syncfusion]
Replied On 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

Jayakumar Paramasivam
Replied On 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 




Seeni Sakthi Kumar Seeni Raj [Syncfusion]
Replied On 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. 


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

;