Page 1 of 1

Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 12:47 pm
by hallworthdesign

I'm struggling to work with the response data and mapping it to labels.
I don't know how to get the service response to pick up the data in the array and show it in different places. I just get all the data shown in one place.

I have set up a REST service to pull data from a Fusion table.
The test request works and returns data fine.

Data response is like this
code
{
"kind": "fusiontables#sqlresponse",
"columns": [
"rowid",
"name",
"description"
],
"rows": [
[
"1001",
"Harlequin Vintage",
"My desc"
],
[
"1002",
"Wolf & Gypsy Vintage",
""
],
[
"1003",
"Artifice Vintage Furniture & Interiors",
""
]
]
}
/code

I clicked 'Automatically Create Service Response' to set the response parameters like below
Image

I map the service to the list components labels

Image

Which shows this
Image

I want to split the response data and show them under different labels.
All I get is
I've worked through the tutorials but can;t spot a similar scenario to work from.

Help!


Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 1:31 pm
by Maryna Brodina

Hello!

As this is array, you can't map each value to a separate element. But you can add Grid with one label and do mapping, see the screenshot.
Image
Another way is to fill in Label value with JS.


Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 2:53 pm
by hallworthdesign

thanks for your reply Maryna, I've tried that but it just seems too give me the same result as when using the list item with labels or am I missing something?
Image


Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 3:20 pm
by Maryna Brodina

Please look at the screenshot I posted and do exactly the same mapping.


Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 3:28 pm
by hallworthdesign

Apologies - I didn't put the grid in a list item and map it properly. I now have my data appearing as separate items - repeating the label for each item.

I don't want to show rowid in a label but as I've requested it in the select statement, it's being displayed. How can I intercept the data response values in javascript so I can format it? Sorry to be a dunce, but I'm trying to understand how this all fits together


Struggling with Fusion table response data

Posted: Wed Mar 12, 2014 6:26 pm
by Nikita

Hello,

You can handle data on mapping with adding JS:
http://docs.appery.io/documentation/r...


Struggling with Fusion table response data

Posted: Thu Mar 13, 2014 9:28 am
by hallworthdesign

Ok thanks Nikita, I hadn't found that page previously


Struggling with Fusion table response data

Posted: Thu Mar 13, 2014 2:24 pm
by hallworthdesign

Finally got this working after 3 days bashing of head.
Hope this helps someone.

I have a single mobileListItem that contains 3 labels.
Labels are populated with data returned from fusion service response.

Here's the response mapping - javascript populates the 3 labels using the 'value' array it is passed.

Image

Javascript is this
code
$('[dsid=rowid]', element).text(value[0]);
$('[dsid=placeName]', element).text(value[1]);
$('[dsid=placeDescription]', element).text(value[2]);
/code


Struggling with Fusion table response data

Posted: Thu Mar 13, 2014 2:40 pm
by Maryna Brodina

Thank you for sharing!