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

[Solved] concatenation in telerik mvc grid

2 Answers 99 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richa
Top achievements
Rank 1
Richa asked on 28 Feb 2012, 01:42 PM
I have a column in my Telerik MVC Grid called as "Patient Name".
In the database, I have "PatientFirstName" and "PatientLastName" as the columns.
I want to display the Patient Name in the grid as (PatientLastName,PatientFirstName).

columns.Bound((o => (o.PatientFirstName + o.PatientLastName))).Title("Patient Name");

 

This is not working.How can I do this?

2 Answers, 1 is accepted

Sort by
0
Accepted
Dadv
Top achievements
Rank 1
answered on 28 Feb 2012, 03:21 PM
Hi,

<%
    Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Template(c => {
                %><%= c.PatientFirstName %>, <%= c.PatientLastName %><%
            }).Title("Patient Name");
        })
        .Render();
 %>

You could change your ViewModel also :

public class PatientViewModel
{
public string PatientFirstName {get; set;}
public string PatientLastName {get; set;} 

public string PatientName {get { return this.PatientFirstName  + ", " + this.PatientLastName  ;}}
}

<%
    Html.Telerik().Grid(Model)
        .Name("Grid")
        .Columns(columns =>
        {
            columns.Bound(c => c.PatientName).Title("Patient Name");
        })
        .Render();
 %>

Regards,
0
Richa
Top achievements
Rank 1
answered on 29 Feb 2012, 06:45 AM
Thanks Dadv. I changed the model and it worked :)
Tags
Grid
Asked by
Richa
Top achievements
Rank 1
Answers by
Dadv
Top achievements
Rank 1
Richa
Top achievements
Rank 1
Share this question
or