Solved

How do you combine fields in a JQGRID?

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
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…

910 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

23 Experts available now in Live!

Get 1:1 Help Now