Solved

How do you combine fields in a JQGRID?

Posted on 2014-02-05
5
364 Views
Last Modified: 2014-02-05
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
0
Comment
Question by:traport
  • 3
  • 2
5 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 39836526
have a look at the Custom Formatter option

example:

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

Open in new window

0
 

Author Comment

by:traport
ID: 39836619
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
 
LVL 33

Accepted Solution

by:
Big Monty earned 500 total points
ID: 39836635
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
 

Author Comment

by:traport
ID: 39836660
That has a column with 'undefined' as the values. I'm stumped.
0
 

Author Closing Comment

by:traport
ID: 39836890
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

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question