How to combine fields in a JSON to a single column, linkify cell contents and otherwise alter things

How to combine fields in a JSON to a single column, linkify cell contents and otherwise alter things

schizoidschizoid Posts: 2Questions: 0Answers: 0
edited July 2013 in General
** Prologue **
I have a CouchDB with a number of JSON documents (that are acquired via a URL that provides a JSON feed, but that's not really part of the question.

I'm building a platform to view -- and potentially process -- these JSON documents. I've actually gotten Datatables up and running with some [static] sample data, so I assume I can figure out how to transition to pulling live data from the CouchDB.
** /Prologue **

My question is: How do I combine fields from the JSON in to one cell in the table, and/or linkify things? In general, how to I alter the contents of the cell as it appears in the HTML table?

As an example, let's say I have a field in my JSON data for "X" and "Y" in terms of lat/long. I can display these independently, but it might be nice to combine them in to a URL which then links to google maps.

I could provide an example, but this is all very general, so hopefully you can see what I'm getting at.

Currently, I might have something like this:


$(document).ready(function() {
var oTable = $('#example').dataTable( {
"bProcessing": true,

"sAjaxSource": "sample.json",

"aoColumns": [
{ "mData": "X" },
{ "mData": "Y" },
]
} );
} );

And then in my HTML:



X
Y



But it would be nice if I could make the value for X, combined with the value for Y in to a link.

In [sloppy] PHP, it'd be something like:
$link = "http://https://maps.google.com/maps?q=" . $X . "," . "$Y";

So THAT is the value I'd like to appear in the table, under a "Location" heading, as opposed to the X,Y headings I have explicitly in the JSON.

Any ideas on how to do something like that?

Replies

  • schizoidschizoid Posts: 2Questions: 0Answers: 0
    So is the answer to this "use jqGrid"?
This discussion has been closed.