How to use bound model data as link text in a grid

2 posts, 1 answers
  1. Kristen
    Kristen avatar
    7 posts
    Member since:
    Dec 2017

    Posted 08 Dec 2017 Link to this post

    Hi, 

    I'm very new to kendo and I've been having issues finding some documentation for this. Basically I have the following grid:

    @(Html.Kendo().Grid<SylectusTL.Models.User.User>()
                    .Name("UserList")
                    .Columns(columns =>
                    {
                        columns.Bound(c => c.user_name).Title("User Name");                    
                        columns.Bound(c => c.full_name).Title("Name");
                        columns.Bound(c => c.main_phone).Title("Phone");
                        columns.Bound(c => c.email).Title("E-Mail");
                        columns.Bound(c => c.admin).Title("Admin");
                        columns.Bound(c => c.active).Title("Active");
                        columns.Bound(c => c.last_login).Title("Last Login").Format("{0:MM/dd/yyyy}");
                    })
                    .Pageable(pageable => pageable
                        .Refresh(true)
                        .PageSizes(new int[] { 10, 20, 50 })
                        .ButtonCount(5))
                    .Sortable()
                    .Scrollable()
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .PageSize(20)
                        .Read(read => read.Action("Users_Read", "Account"))
                    )
                    )

     

    What I would like to do is make the user name a link that calls my controller and passes the user id to it. I'm having issues finding a way to use the models user_name parameter for the link text and the models user_id parameter in the url.

     

  2. Answer
    Georgi
    Admin
    Georgi avatar
    665 posts

    Posted 12 Dec 2017 Link to this post

    Hello Kristen,

    A possible solution is to use column template:

    columns.Bound(c => c.user_name).Title("User Name").ClientTemplate("<a href='/Controller/Action?username=#=user_name#&id=#=user_id#'>#=user_name#</a>");


    Regards,
    Georgi
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top