- Home
- Forum
- ASP.NET MVC - EJ 2
- Combining two database field to show in one column
Combining two database field to show in one column
So in building the view in the cshtml file we specify the columns
<div class="row">
<ejs-grid id="GridDetail" allowFiltering="true" allowSorting="true" allowGrouping="false" enableHover="true" rowHeight="38" allowPaging="true" dataSource="ViewBag.students" allowSelection="true">
<e-grid-pagesettings pageSizes="true" pageSize="10"></e-grid-pagesettings>
<e-grid-filtersettings type="Menu"></e-grid-filtersettings>
<e-grid-columns>
<e-grid-column field="ResidencyStatus" headerText="Residency Status" filter="@(new { type="CheckBox"})" clipMode="EllipsisWithTooltip" width="170"></e-grid-column>
<e-grid-column field="LastName" headerText="Last Name" filter="@(new { type="CheckBox"})" clipMode="EllipsisWithTooltip" width="170"></e-grid-column>
<e-grid-column field="HomeDistrictId" headerText="District" filter="@(new { type="CheckBox"})" clipMode="EllipsisWithTooltip" width="170"></e-grid-column>
</e-grid-columns>
</ejs-grid>
</div>
I need to combine columns LastName and FirstName together with a Header "Student" and result displayed as LastName, FirstName
I don't see any examples of how to do it or the documentation on this very common need except this
- You can use the Grid column template which allows to display custom elements for achieving your requirement. More details on this can be checked in the below documentation link,
|
<script id="template" type="text/x-template">
<div>
${FirstName} - ${LastName}
</div>
</script> |
- You can also use the value accessor feature approach mentioned in your update to achieve the requirement. More details on this can be checked in the below documentation link,
- 1 Reply
- 2 Participants
-
AK Alex Kleyman
- Aug 20, 2021 08:20 PM UTC
- Aug 23, 2021 10:51 AM UTC