I can not find a way to read the items in a UI ListBox object. I have search and found some methods like getItemCount() and getItemText() in the Google Web Toolkit but they are not available when using the object in a javascript.....
Any ideas?
You will have to pass the list-box widget trough a Server Side call to get the selected data out of it:
function doGet(){
var app = UiApp.createApplication();
var lb = app.createListBox();
lb.setName("calName") //name used to fetch selected result
.addItem("Text Option One", "1")//options for selection
.addItem("Text Option Two","");//first peram display text and second peram value
app.add(lb); // adds listbox to display
app.add(app.createButton("Click Me")//create button
.addClickHandler(app.createServerHandler("showResult") // Create server side execution to handel click
.addCallbackElement(lb))); // add list-boxas element to be passed to server as parameter
return app;
}
function showResult(e){
var app = UiApp.getActiveApplication();
var res = e.parameter.calName;//parameter name same as list-box name given
app.add(app.createLabel("Selected option is " + res));//displays selected option
return app;
}
just create test app and save a version, Use this code for application and view latest code after deploying it.
Related
I've started to receive reports that the add-on we have been using for a while stopped working on iOS mobile. I was able to confirm this and started to dig into the issues. I've been able to reproduce the error with the "Quickstart: Cats Google Workspace Add-on" using multiple google accounts (gmail and workspace). It appears that cards, navigation, and notifications being returned from a function called by a button in card do not render on iOS Gmail. The code appears to work on desktop. I was able to demo this with the Quickstart tutorial. I removed the need for whitelist urls on mobile using the following createCatCard that shows the current time instead of a cat picture. This project works on desktop but not on iOS Gmail.
I've reported this to google via their issue tracker (https://issuetracker.google.com/issues/210484310) but they state that "The Issue Tracker is intended for reporting issues and asking for features related to development with/on Google products, therefore it is not the best place to ask for support on this matter."
Does anyone know if iOS Gmail add-ons are still supported and if there is a workaround for this behavior?
/**
* Creates a card with an image of a cat, overlayed with the text.
* #param {String} text The text to overlay on the image.
* #param {Boolean} isHomepage True if the card created here is a homepage;
* false otherwise. Defaults to false.
* #return {CardService.Card} The assembled card.
*/
function createCatCard(text, isHomepage) {
// Explicitly set the value of isHomepage as false if null or undefined.
if (!isHomepage) {
isHomepage = false;
}
// Use the "Cat as a service" API to get the cat image. Add a "time" URL
// parameter to act as a cache buster.
var now = new Date();
// Replace formward slashes in the text, as they break the CataaS API.
var caption = text.replace(/\//g, ' ');
var d = new Date();
var textLabel = CardService.newTextParagraph().setText("Current Time." + d.toLocaleTimeString());
// Create a button that changes the cat image when pressed.
// Note: Action parameter keys and values must be strings.
var action = CardService.newAction()
.setFunctionName('onChangeCat')
.setParameters({text: text, isHomepage: isHomepage.toString()});
var button = CardService.newTextButton()
.setText('Change cat')
.setOnClickAction(action)
.setTextButtonStyle(CardService.TextButtonStyle.FILLED);
var buttonSet = CardService.newButtonSet()
.addButton(button);
// Assemble the widgets and return the card.
var section = CardService.newCardSection()
.addWidget(textLabel)
.addWidget(buttonSet);
var card = CardService.newCardBuilder()
.addSection(section);
if (!isHomepage) {
// Create the header shown when the card is minimized,
// but only when this card is a contextual card. Peek headers
// are never used by non-contexual cards like homepages.
var peekHeader = CardService.newCardHeader()
.setTitle('Contextual Cat')
.setImageUrl('https://www.gstatic.com/images/icons/material/system/1x/pets_black_48dp.png')
.setSubtitle(text);
card.setPeekCardHeader(peekHeader)
}
return card.build();
}
I am developing a master detail Fiori app using SAP UI5. As the details contains more than 40 columns, I made separate OData services for master & detail.
In Master page, data are coming correctly. Now my task is that on any table line, when user clicks on Detail, next page will be open with details base on two key values of master table.
I'm getting two keys in variables in detail page as follows and it is working fine:
var spayid = jQuery.sap.getUriParameters().get("payid");
var spaydt = jQuery.sap.getUriParameters().get("paydt");
Next, I have created two filters as follows which is also working fine.
var filter1 = new Filter({
path: "Laufi",
operator: FilterOperator.EQ,
value1: spayid
});
var filter2 = new Filter({
path: "Laufd",
operator: FilterOperator.EQ,
value1: spaydt
});
Now I am calling OData service which is also working fine:
var oODataModel = new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/ZASA_FI_pay_D_SRV?sap-client=100", {
json: true,
useBatch: false
});
this.getView().setModel(oODataModel);
I don't know now how to filter data. What should be included in above so that it will filter data according to my filters filer1 and filter2? I have tried following but it is not working.
filters : [ filter1, filter2 ],
json: true,
useBatch: false
I am very good in ABAP but not an expert in SAPUI5. I am in learning phase.
First of all, I was thinking to pass parameters on OData service so that only the required data are fetched. Means my OData call should be like this:
new ODataModel("proxy/http/FIORI-DEV.abc.com:8000/sap/opu/odata/sap/ZASA_FI_PAYMENT_D_SRV/PdetailSet(Laufi= spayid, Laufd = spaydt)?sap-client=100");
But this seems not like possible.
Second option is that I will fetch whole details in OData service and then during binding to table I will apply filter.
The purpose of the sap.ui.model.Filter class is usually to apply filters to lists on the UI. For example, if you have a list of items and you want to limit that list to a subset of items which fulfills certain criteria.
But what you have here appears to be a classic master-detail scenario where you have a list of items and then when the user selects one show more information about that one item.
The usual solution for such a scenario is to assign the full model to the detail-view and then use an element binding (also known as "context binding") on the view to tell it which item to display.
When the source of the item is a click on an element which already had an element binding, then you can actually retrieve the correct binding path from the click event and just apply it to your detail-view.
From one of the official demos:
onItemSelected: function(oEvent) {
var oSelectedItem = oEvent.getSource();
var oContext = oSelectedItem.getBindingContext("products");
var sPath = oContext.getPath();
var oProductDetailPanel = this.byId("productDetailsPanel");
oProductDetailPanel.bindElement({ path: sPath, model: "products" });
}
When you don't have any convenient way to get an element path from, then you have to construct one yourself:
var detailPanel = this.getView().byId("idOfDetailPanel");
detailPanel.bindElement("PdetailSet(Laufi = " + spayid +", Laufd = " + spaydt + ")");
The latter code snippet does of course assume that the oData-service actually supports access with a key consisting of laufi and laufd. This is decided by:
The definition of the key fields of the entity type in the SAP Gateway Service Builder (transaction SEGW)
The ABAP implementation of the method get_entity of the data provider class of that oData-service.
Is it possible to write your own custom function in google sheets script that returns a drawn image, similar to how the SPARKLINE function works, except I want to make one that draws a pie chart instead.
I do not want to use Insert > Chart... > Pie Chart because that creates a floating chart on top of the spreadsheet. I would like to be able to write my own function that would return a pie chart that is embedded within the cell that the function is entered in, just like you can do with columns, bars, and line charts using sparkline.
How about following idea? This sample script embeds a chart to a cell using custom function on Spreadsheet. I think that this method is one of various ideas.
Problems :
When you want to create a chart and embed it to a cell using custom functions, you notice that insertChart() cannot be used. There are some limitations for using custom functions. But insertChart() creates floating charts. So in order to embed a chart to a cell, the function =IMAGE() is suitable for this situation. Here, setFormula() for setting =IMAGE() and DriveApp.createFile() for creating images from charts also cannot be used for custom functions.
Solution :
In order to avoid these limitations, I used Web Apps.
To use this sample script, please deploy Web Apps as follows.
On the Script Editor,
File
-> Manage Versions
-> Save New Version
Publish
-> Deploy as Web App
-> At Execute the app as, select "your account"
-> At Who has access to the app, select "Anyone, even anonymous"
-> Click "Deploy"
-> Copy "Current web app URL"
-> Click "OK"
When it deploys Web Apps, the approval required authorization can be done, simultaneously.
Sample Script :
Please copy and paste this script to a bound script of spreadsheet.
var folderId = "### Folder ID ###"; // This is a folder to save images.
var webappsurl = "https://script.google.com/macros/s/######/exec"; // Here, please put "Current web app URL".
function embedChart(range) {
var ac = SpreadsheetApp.getActiveSheet().getActiveCell();
var q1 = "?datarange=" + range;
var q2 = "&row=" + ac.getRow();
var q3 = "&col=" + ac.getColumn();
var url = webappsurl + q1 + q2 + q3;
UrlFetchApp.fetch(url);
}
function doGet(e) {
var sheet = SpreadsheetApp.getActiveSheet();
var chart = sheet.newChart()
.setChartType(Charts.ChartType.PIE)
.addRange(sheet.getRange(e.parameters.datarange))
.setOption('height', 280)
.setOption('width', 480)
.setOption('title', 'Sample chart')
.build();
var file = DriveApp.getFolderById(folderId).createFile(
chart.getAs('image/png').setName("chart_image.png")
);
file.setSharing(DriveApp.Access.ANYONE_WITH_LINK, DriveApp.Permission.VIEW);
sheet.getRange(e.parameters.row, e.parameters.col).setFormula(
'=IMAGE("' + "http://drive.google.com/uc?id=" + file.getId() + '")'
);
}
Flow of Script :
embedChart()
Input =embedChart("a2:a6") in cell B7.
Using fetch(), sends data of a2:a6 and the inputted coordinate to doGet().
doGet()
Using doGet(), get the data.
Creates a chart using inputted range a2:a6. (in this case, creates a pie chart)
Saves a chart as an image. (in this case, saves as PNG)
Updates a permission of the image file to use for =IMAGE().
Embeds the image using =IMAGE() which was imported by setFormula().
Result :
By inputting =embedChart("a2:a6") in cell B7 as a custom function, following result can be obtained.
Note :
When the custom function embedChart() is used, loading time is about 40 seconds. (I don't know whether this occurs at only my environment.)
Permissions of the created image are ANYONE_WITH_LINK, VIEW.
embedChart() is overwritten by =IMAGE(). So when the spreadsheet is reopened, the response of =IMAGE() is much faster than that of embedChart().
If I misunderstand your question, I'm sorry.
I'm working on a simple Master detail SAPUI5 app.
I use V2 Odata Model an TwoWay binding.
When I click on the submit button I want to get all the values entered by the user in the model.
The problem is that I get only header data but not items data.
I need both in order to use the create deep entity method in the backend.
Here is my code:
var sPath = evt.getSource().getBindingContext().getPath();
var myData = evt.getSource().getBindingContext().getObject(sPath);
In myData I get the header data and the navigation propoerty with no data in it.
How can I get the items data as well ?
I tried with expand but no success !
Have you tried to do it in the following way ?
var sPath = evt.getSource().getBindingContext().getPath(),
var myData = yourModel.getProperty(sPath);
If you model has a particular name you could do something like this -
var sPath = evt.getSource().getBindingContext("modelName").getPath(),
var myData = this.getView().getModel("modelName").getProperty(sPath);
You always need to get the path, and using it, you get the value in that path for the model
I have a data grid with multiple columns among which one is for stock date. Based on the data i am getting from the backend,when a flag is disabled,i want the date to be displayed as a label,otherwise i want the start date to be editable date field. How can this be done? I have tried this below code but its takes the last rendered item as item renderer. Cause as i loop in,the condition for different records change and rendering it this way doesnt seem to work. Please help.
private function resultHandler_tbd(event:ResultEvent):void{
var myAC: ArrayCollection= event.result as ArrayCollection; //data from backend
myDataGridId.dataprovider= myAC;
for(var i:int=0;i<myAC.length;i++){
mylist=myAc[i];
if(mylist.tbdType=="Plan" && flag==true){
plnStartDate.itemrenderer= new ClassFactory(CustomCalenderRenderer);
}else
plnStartDate.itemrenderer = new ClassFactory(CustomLabelRenderer);
}
}
}
Have the "flag" property set in data for item renderer
Create a custom itemrenderer which will have both component, CustomCalenderRenderer and CustomLabelRenderer and binded with data.flag for includedInLayout or not
Thanks