Hello,
I have a data source like:
var dataSource = [
{
User: {
ID: '123',
Name: {
First: 'Jack',
Last: 'Doson'
}
]
I want to show it in an igGrid, primary key is User.ID, column 'UserID' is User.ID, column 'UserName' is 'User.Name.First + User.Name.Last'.
How can I do it? Thanks!
Thank you for contacting us.
About your question, basically you can, you can specify responseDataKey to be "User" and after that to use column formatter in order to combine first and last name, although I do not recommend you to use this approach, because it is a lot difficult to implement and my suggestion is to use igHierarchicalGrid. This grid is suppose to work with this kind of data, not the igGrid.
Useful references:
http://help.infragistics.com/jQuery/2014.1/ui.iggrid#options
http://help.infragistics.com/jQuery/2014.1/ui.ighierarchicalgrid
Code snippet:
Looking forward to hearing from you.
Still don' tknow how to display First + Last.
What is the 'val' in the formatter function?
Hello Zach Shine,
Thank you for your reply,
I have changed my mind about the formatter, lets try something better, lets use our column template. With it we can fulfill your requirements. I have created a sample in order to show you my approach. Basically we have template with which we format First and Last name to be concatenated.
Online sample:
http://jsfiddle.net/zdravko/Wnf8q/2/
Thank you for your reply. Your code works!
Can I use fields other than Name in the template?
For example, I have a Gender filed:
var ds = { User: [{ ID: 123, Name: { First: 'Jack', Last: 'Doson' }, Gender: 'M' }] };
And I want to show Mr./Ms. according to the Gender in the template (fake code) as below:
Is it possible?
Yes you can, although your IF statement must be defined like:
I have modified the online sample:
http://jsfiddle.net/Wnf8q/5/
Thank you very much!~~~
I am glad that I've managed to help you.
Thank you for using our products.