How do you combine fields in a JQGRID?

Instead of this:
{name:'lastname', label: 'Last Name', index:'lastname', width:200},
{name:'firstname', label: 'First Name', index:'firstname', width:250},

Open in new window


I essentially want: Last Name, First Name
traportAsked:
Who is Participating?
 
Big MontyConnect With a Mentor Senior Web Developer / CEO of ExchangeTree.org Commented:
i believe you would do something like this:

{name:'fullName', label: 'Full Name', index:'fullName', width:200, formatter:'myFormatter'},

function myFormatter(cellvalue, options, rowObject){
    return rowObject.firstName + " " + rowObject.lastName;
}

Open in new window

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
have a look at the Custom Formatter option

example:

function myFormatter(cellvalue, options, rowObject){
    return rowObject.firstName + " " + rowObject.lastName;
}

Open in new window

0
 
traportAuthor Commented:
Thank you. I just can't seem to figure out how to incorporate that into my grid as a column.

Is it a new column? i.e.

{name: 'fullname', formatter:myFormatter, index... then what?}
0
 
traportAuthor Commented:
That has a column with 'undefined' as the values. I'm stumped.
0
 
traportAuthor Commented:
This was correct, I just had to lower case the 'n'. I had to place the function about my document.ready as well. Thanks so much.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.