I'm using the gapi.client.sheets.spreadsheets.create() method and passing in an object to create a spreadsheet with some predefined values.
I've tried various implementations and haven't yet succeeded in pulling it off. I'm referring to the docs here: https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets#CellData.
My Object looks something like this:
'sheets': [{
"properties": {
"sheetId": 1,
"title": "Summary",
"index": 0,
},
"data": [
{
"startRow": 0,
"startColumn": 0,
"rowData": [
{
"values": [
{
"hyperlink": "=HYPERLINK('https://google.com')"
}
]
}
}
]
]
Google says: "To set it, use a =HYPERLINK formula". Is this not the hyperlink formula? When the spreadsheet renders the hyperlink field is blank. (I want to display a link to a website). How can this be set?
The documentation for the hyperlink field is "A hyperlink this cell points to, if any. This field is read-only. (To set it, use a =HYPERLINK formula.)". You're still setting the hyperlink field (although you're attempting to set it to a formula). That won't work, because the field is read only. To set a formula, set a value in userEnteredValue.formulaValue. That will set a formula on the server, and the hyperlink field will be populated as a result.
You can also use 'USER_ENTERED' if using batchUpdate:
sheets.spreadsheets.values.batchUpdate({
spreadsheetId,
valueInputOption: 'USER_ENTERED',
requestBody: {
data:[
range: *your range*
values:[['=HYPERLINK("google.com", "ciao")']]
],
},
})
This way you basically put there the formula and the api interprets as if the user entered the formula
Related
I am working on Shopify and creating a d3 chart.
I tried to pass data from Shopify liquid to javascript.
The codes are as shown in the fiddle.
var temp_test = {
"events": []
};
var test = [
[
"<p>Everything is fresh. delicious and good.</p>",
undefined,
"12-23-2000",
"test",
"Start"
],
[
"<p>Everything is fresh. delicious and good.</p>",
undefined,
"12-23-2000",
"test",
"Start"
]
];
test.forEach(function(data) {
temp_test.events.push({
"title": data[0],
"image": data[1],
"date": data[2],
"content_1": data[3],
"content_2": data[4]
});
});
console.log('check for nan', temp_test);
https://jsfiddle.net/be83yk54/22/
(Strangely, the fiddle works just fine but Shopify does not and it is not Shopify problem).
console.log shows the data just fine, but when I click on the data to expand the object, the string is converted to number automatically and I got NaN instead of formatted date.
I think I got what happened. When I console.log the data the data correct. but the array object might be manipulated in d3 which caused the object data change and when expanding the object, the data is already changed.
I have been trying to get resources using GET Request. You can see the actual Query here:
{ "success": true,"data": [
{
"ID": 123
"Code": "Test",
"Enabled": true,
"Flags": 0,
"Niveau": 0,
"SQL": "SELECT GEMEENTE.GM_ID,\r\n GEMEENTE.GM_POSTNUMMER,\r\n
GEMEENTE.GM_DEELGEMEENTE,\r\n GEMEENTE.GM_LAND_FK,\r\n
LAND.LN_ACTIEF\r\nFROM GEMEENTE\r\n LEFT JOIN LAND ON GEMEENTE.GM_LAND_FK =
LAND.LN_ID\r\nWhere GM_VERANDERDOP >=:ChangedOn",
"Parameters": [
"ChangedOn"
],
"QueryType": 0
}]}
However I need to pass an Argument to the "Parameters" property so i can actually see the response data. I see "ChangedOn" is a the argument array I need to set to a date. I tried this: http://localhost/A/B/server.fcgi/Query?Code=Test&Parameters="2015-07-05T22:16:18Z"
I am working with javascript and vue.
What are we looking at here? Is this the server code of your API. In that case, it looks like you need to supply a ChangedOn parameter. Also, your query string should be url encoded. Try calling...
http://localhost/A/B/server.fcgi/Query?Code=Test&ChangedOn=22015-07-05T22%3A16%3A18Z
I am trying to learn promises in javascript and I came across this short video tutorial, there is a complete code from it on plunker.
What I wonder about in this code is in this line in promises.js file:
return $.get('tweets.json?id=' + profile.id);
First of all, why do we even need to pass any parameters there, since there is no profile.id field in tweets.json file, and when removing it I get the same results. If there was that field in tweets.json how would we achieve to get only tweets from the users that we pass with get request?
I have tried something like this but it doesn't work:
In promises.json I have changed the get request to:
return $.get('tweets.json?profile=' + profile.id);
And have added a new field to the tweets.json file, but only to the first tweet:
{
"id": 1,
"profile": 12302151,
"tweet": "OMG, worst day ever, my BF #BobbyBoo dumped me",
"usersMentioned": [
{
"id": 10,
"username": "BobbyBoo"
}
]
},
I was then expecting that I will only get that one tweet for that user, but I am still getting the whole list
For now I have
require([
"dojo/on", "dgrid/OnDemandGrid","dgrid/Tree","dgrid/Editor", "dgrid/Keyboard", "dojo/_base/declare",
"dgrid/data/createHierarchicalStore", "data/projects_data",
"dojo/domReady!"
], function(
on, Grid, Tree, Editor, Keyboard, declare, createHierarchicalStore, hierarchicalCountryData
){
var count = 0; // for incrementing edits from button under 1st grid
function nbspFormatter(value){
// returns " " for blank content, to prevent cell collapsing
return value === undefined || value === "" ? " " : value;
}
var StandardGrid = declare([Grid, Keyboard, Editor, Tree]);
window.grid = new StandardGrid({
collection: createHierarchicalStore({ data: hierarchicalCountryData }, true),
columns: [
{renderExpando: true, label: "Name", field:"variant_name", sortable: false, editor: "text", editOn: "dblclick"},
{label: "Visited", field: "bool", sortable: false, editor: "checkbox"},
{label:"Project", field:"project", sortable: false, editor: "text", editOn: "dblclick"},
{label:"locked", field:"locked", editor: "text", editOn: "dblclick"},
{label:"modified", field:"modified", editor: "text", editOn: "dblclick"},
{label:"summary", field:"summary", editor: "text", editOn: "dblclick"}
]
}, "treeGrid2");
grid.on("dgrid-datachange", function(evt){
console.log("data changed: ", evt.oldValue, " -> ", evt.value);
console.log("cell: ", evt.cell.row.id, evt.cell.column.field);
});
grid.on("dgrid-editor-show", function(evt){
console.log("show editOn editor: ", evt);
});
grid.on("dgrid-editor-hide", function(evt){
console.log("hide editOn editor: ", evt);
});
});
data/projects is a js file containing the data. but how to connect this dGrid now to a MySQL database? Can't find any good information in the docs. I think might be something with JSON rest but not sure about this.
Addition:
I can show the db in an HTML Table. is there a suitable possibilty to populate dGrid from a HTML Table?
I am still missing something. Have connections from
Database -> PHP
but can't get result in a proper JS to load into dStore.
The simplest path forward is to write a service in your server-side language of choice (sounds like PHP in this case) that produces JSON output based on the data in your MySQL database. Depending on the potential size of your data, you can potentially design your data to work with one of two out-of-the-box stores in dstore: Request (and Rest if write operations are also involved), or RequestMemory.
The simpler of the two is RequestMemory, which simply combines the features of the Memory store with an up-front server request (via Request). This store will expect the service to respond with one complete data payload: an array of objects where each object is a record in your database. Something like this:
[
{
"id": 1,
"foo": "bar"
},
{
"id": 2,
"foo": "baz"
}
]
The Rest store expects data in the same format, but also expects the service to handle filtering, sorting, and ranges. Filtering and sorting are represented via query string parameters (e.g. foo=bar&baz=bim in the simplest case for filter, and sort(+foo) or sort(-foo) for sort), while ranges are typically represented via the HTTP Range header (e.g. Range: Items 0-9 for the first 10 items).
Implementing a service for the Rest store is obviously more work, but would be preferable if you're expecting your data source to potentially have thousands of items, since RequestMemory would have no choice but to request all of the items up-front.
With either of these stores, once you have a service that outputs JSON as appropriate, you can create an instance of the store with its target pointing to the service endpoint, then pass it to a grid via the collection property.
If your data is intended to represent a hierarchical structure, it should still be possible to mix dstore/Tree into dstore/RequestMemory or dstore/Request, provided that your hierarchy is represented via parent ID references. By default, Tree filters children via a parent property on each item, and reports mayHaveChildren results by inspecting a hasChildren property on each item.
I have a Maps Engine map with one of the layers linked to a data table containing a single location. I would like to update the data table via JavaScript in Google Sites. The mapsengine.tables.features.batchPatch seems to do what I want, and the help page for the batchInsert version of the same command seems like it could be modified to do what I want. However, I'm having difficulty getting it to work properly. I believe the problem is due to the fact that I don't know what the primary key is for this table or where I can find it (see here for more explanation).
Can anyone here tell me if I'm headed in the right direction, and how I might be able to find this primary key (it also seems to be referred to as a gx_id at times)? Thanks in advance for whatever help you may be able to provide.
Edit: When I go here and get the information on my table, I get the following response:
{
"tables": [
{
"id": {My Table ID},
"etag": "\"6030101253664097613\"",
"projectId": {My Project ID},
"name": "Current Location",
"description": "",
"tags": [
],
"writersCanEditPermissions": false,
"sourceEncoding": "UTF-8",
"processingStatus": "complete",
"bbox": [
-180,
-90,
180,
90
],
"creationTime": "2014-11-11T21:33:43.982Z",
"lastModifiedTime": "2014-11-12T20:55:20.613Z"
}
]
}
As you can see, there is no gx_id listed. Is there some way to add it, or do I need to recreate the table to be able to add it from the start? If I need to recreate the table, what do I need to do to make sure the gx_id is there, since it wasn't immediately apparent when I created the table last time that anything was missing.
Yes, that should work fine. You can find your gx_id simply by fetching a copy of your table and checking the properties. Here's a sample from the docs:
Request:
https://www.googleapis.com/mapsengine/v1/tables/12421761926155747447-06672618218968397709/features?maxResults=500&version=published&key=(YOUR_KEY_HERE)
Response:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
149.23531999999997,
-35.352484
]
},
"properties": {
...
"gx_id": "1" <-- HERE
}
},