Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC Kendo Grid Hyperlink column

I want this first column 'Name' should be a 'hyperlink' template .But value should be binded from model for that hyper link each link have different name that comes from property of the model. How to do this? I tried in the following way its working good .!!

But I am getting all rows first column's hyperlink text as "Show Product Details". I want to get model values. I don't want it to be same for all columns

 @(Html.Kendo().Grid<Cutomers.Model.CustomerDataModel>()
        .Name("grid")
        .Columns(columns =>
        {
          columns.Bound(p => p.Name).ClientTemplate("<a href='" +Url.Action("ProductDetails", "Product") +"/#= FileName #'" +">Show Product Details</a>");
            columns.Bound(c => c.CreatedDate).Width(70);
            columns.Bound(c => c.CreatedBy).Width(70);
                  })

        .HtmlAttributes(new { style = "height: 350px;" })
        .Scrollable()
        .Groupable()
        .Sortable()
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(1))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Customers_Read", "Home"))
        )
    )
like image 231
7783 Avatar asked Feb 11 '23 11:02

7783


1 Answers

I don't think you can use Razor syntax in there, try..

.ClientTemplate("<a href=\"Controller/Action/#ModelPropertyHere#\">#AnotherModelPropertyHere#</a>")
like image 93
Gareth Hopkins Avatar answered Mar 03 '23 01:03

Gareth Hopkins