This is a migrated thread and some comments may be shown as answers.

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

1 Answer 567 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kristen
Top achievements
Rank 1
Kristen asked on 08 Dec 2017, 06:10 PM

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.

 

1 Answer, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 12 Dec 2017, 08:14 AM
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.
Tags
Grid
Asked by
Kristen
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or