Solved

How do you combine fields in a JQGRID?

Posted on 2014-02-05
5
361 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 32

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 32

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now