- Home
- Forum
- ASP.NET MVC - EJ 2
- Concat Two Fields in One Column
Concat Two Fields in One Column
3 Replies
MF
Mohammed Farook J
Syncfusion Team
June 19, 2018 01:58 PM UTC
Hi Breno,
We have achieved your requirement by using ‘ValueAccessor’ property of Grid. The valueAccessor is used to access/manipulate the value of display data. You can achieve custom value formatting by using the valueAccessor. Please find the code example.
|
@Html.EJS().Grid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>
{
col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add();
col.Field("FirstName").HeaderText("Full Name").Width("150").ValueAccessor("valueAccess").Add();
}).Render()
</div>
<script>
function valueAccess(field, data, column) {
return data[field] + '-' + data['LastName'];
}
</script>
|
Please find the documentation for your reference.
Regards,
J Mohammed Farook
Hi Breno,
We have achieved your requirement by using ‘ValueAccessor’ property of Grid. The valueAccessor is used to access/manipulate the value of display data. You can achieve custom value formatting by using the valueAccessor. Please find the code example.
@Html.EJS().Grid("DefaultFunctionalities").DataSource((IEnumerable<object>)ViewBag.dataSource).Columns(col =>{col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Width("120").Add();col.Field("FirstName").HeaderText("Full Name").Width("150").ValueAccessor("valueAccess").Add();}).Render()</div><script>function valueAccess(field, data, column) {return data[field] + '-' + data['LastName'];}</script>
Please find the documentation for your reference.
Regards,J Mohammed Farook
Hi Mohammed Farook J, May you send me a working example, because I could not make it work on my project.
Thank you.
By Breno Laustidio.
MF
Mohammed Farook J
Syncfusion Team
June 21, 2018 05:08 AM UTC
Hi Breno,
We have prepared a sample based on your requirement and you can downloaded from the following link
Sample : http://www.syncfusion.com/downloads/support/directtrac/general/ze/WebApplication26-1631990286.zip
Regards,
J Mohammed Farook
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
BL Breno Laustidio
- Jun 18, 2018 04:04 PM UTC
- Jun 21, 2018 05:08 AM UTC