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

[Solved] Multiple fields into Single Column

2 Answers 255 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.
Ashok
Top achievements
Rank 1
Ashok asked on 07 Jun 2011, 05:15 PM
I want to display multiple field into Single Column in Telerik MVC grid. How can i achieve?
Here is what I have:
  
.Columns(columns =>
        {
            columns.Bound(o => o.Field1).Width(200);
            columns.Bound(o => o.Field2).Width(200);
            columns.Bound(o => o.Field3).Width(200);
            columns.Bound(o => o.Field4).Width(200);
        })
  
Here is what I want:
  
.Columns(columns =>
        {
            columns.Bound(o => o.Field1 + o.Field2).Width(400);
            columns.Bound(o => o.Field3 + o.Field4).Width(400);
        })

Reason I want it like this is because I am using fields seperately in controller. Only for purpose of UI I need them like this.
I think I use something like this, but I can't make it work with Razor view.

columns.Bound(o => o.Field1).Template(o=> { @o.Field1 @o.Field2     }).Width(200);

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 08 Jun 2011, 07:04 AM
Hello Tejas,

 Here is how to set the template in razor:

columns.Bound(o => o.Field1).Template(@<text>
@item.Field1
@item.Field2
</text>
).Width(200);

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Neil Watts
Top achievements
Rank 1
answered on 03 Apr 2012, 11:52 PM
Hi Atanas,

Is it possible to accomplish this using a partialview and a gridmodel.

I have a dynamic grid where I build the columns based on search criteria. I utilize the GridColumnSettings[] to build the dynamic data columns. This is no problem and I can display the data as needed.

But now I have a situation where I need a Column Header of a Part Name. Below this I need to show a quantity(SUM) of all parts of that type in an order and below that the cost. All of these will be in the Header Column header.

Below that will be all the actual data.

I dont know how to accomplish this since I am using a dynamic partialview.

Any help would be appreciated.
Tags
Grid
Asked by
Ashok
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Neil Watts
Top achievements
Rank 1
Share this question
or