Adding a column containing a hyperlink for each row in a KendoUI network control in ASP.NET MVC

Here is my view containing the KendoUI network control: I want to add a new column containing a hyperlink before the Created Date column.

@using Kendo.Mvc.UI 
@model IEnumerable<ExamplekendoDropdown.Models.FacilityGroup>



@{
    ViewBag.Title = "Grid";
}



<table width="700">
<tr>
<td align="center">


<table width="1000">
<tr>
<td align="left">
@using (Html.BeginForm("Grid", "Grid", FormMethod.Get))

{
    <table>
    <tr>
    <td>
    <span>Facility Group Name</span>
    </td>
    <td>
    @(Html.Kendo().AutoComplete()
                   .Name("FacilityGroupName")
                   .Value("")
                   .Enable(true)
                ) 
    @Html.Hidden("FacilityGroupName")
    </td>
    </tr>
    <tr>
    <td>
    <input id="Submit1" type="submit" value="Search" />
    </td>
    </tr>
    </table>
}

</td>
</tr>
<tr>
<td align="center" >
@(Html.Kendo().Grid(Model)
    .Name("Grid")

    .Columns(columns =>
        {
                columns.Bound(p => p.FacilityGroupId);

                    //columns.Bound(@Html.ActionLink("Create Facility", "Facility"));


                columns.Bound(p =>p.FaclityGroupName);
                columns.Bound(p => p.status).Width(80);
                columns.Bound(p => p.CreationDate);
                columns.Command(command => { command.Edit();  });
        })

        //.ToolBar(toolbar =>toolbar.Create())
        //.Editable(editable => editable.Mode(GridEditMode.PopUp))

        .Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditUserPopupTemplate")
            .Window(w => w.Title("Facility").Name("editWindow").Width(300).Height(300)))
        .Pageable()
        .Sortable()
        .Scrollable()
        .DataSource(datasource => datasource
            .Server()
            .Model(model => model.Id(p => p.FacilityGroupId ))
            .Read("Grid", "Grid")
            .Update("Update", "Grid")

            //.Create("Create","Grid")
            //.Destroy("Destroy","Grid")
            )
                )

<script type="text/javascript">
    $(document).ready(function () {
        $("form.k-edit-form").kendoValidator();
    });

</script>

</td>
</tr>
</table>


 </td>
</tr>
</table>

Now I need to add another column before the Creation Date column, which contains the hyperlink. Please share your materials Thank you

+5
source share
6 answers
columns.Template(@<text></text>)
       .ClientTemplate("<a href='" + Url.Action("Index", "Home") + "'>Create Facility</a>")
       .HtmlAttributes(new { style = "text-align: left;" })
       .Width(60);

It worked for me

+2
source

But why not if you use ajax

Ajax().ClientTemplate("<a href='" + Url.Action("YourAction", "YourController") +"/#= Id #'" +">#=FileName#</a>");

if server()
columns.Bound(p => p.ProductID).Template(@<text>
                 @Html.ActionLink("Show Product Details", "ProductDetails", new { id = @item.ProductID } )>
                 </text>);

This example

+12
source
columns.Template(@<text></text>).ClientTemplate(
    @Html.ActionLink("Send Reset Email", "Login", new { loginButton = "reset",activate=true,fromAdmin=true,rowField="#=rowField#" }).ToHtmlString()
);

.

+4

Template ClientTemplate, .

columns.Bound(p => p.CreationDate)
    .Template(@<text><a href="">@item.CreationDate</a></text>)
    .ClientTemplate("<a href=''>#CreationDate<a/>").Title("Link");
columns.Bound(p => p.CreationDate);
+2

You need to use the Template method to bind to the server. (ClientTemplate is for Ajax bindings). You do not need to bind it to a specific property if you do not want to associate the column heading with a filter / sort / group by this property.

columns.Template(@<text>@Html.ActionLink("Create Facility", "Facility")</text>)
+2
source

If your grid has a server binding, use this:

  columns.Bound(x => x.ProjectCode)
          .Template(items => Html.ActionLink(items.ProjectCode, "Manage", "Project", new {projectId = items.ProjectId}, null));
0
source

All Articles