Dependent dropdown in table columns / widget - google-app-maker

Is there a way to have dependent dropdown in table columns? Example in table A I have ColumnA1 & ColumnB1, both have dropdowns, B1 dropdown values should be filtered based on Value selected in A1. Any help on this is really appreciated.
Example:
I have a page with Tabular data entry, few columns in table has Dropdown attached. I want to filter data in dropdown based on value selected in previous column in same row.
I am unable to find any code example in Appmaker help or in templates.
Can someone please help me to achieve dependent dropdown in Table widget?

You can accomplish this by attaching an event property to A1.
For example, on dropdown A1's onValueChange event:
updateB1(newValue);
In a client-side script, write the following:
function updateB1(valueOfA1) {
var widgetB1 = app.pages.<page>.descendants.DropdownB1;
// Re-define dropdown B1's options - your filter goes here
widgetB1.options = ["array","of","options"];
widgetB1.names = ["array","of","names"]; // this one is optional
}
All the logic for what values appear in B1, depending on A1's value, would be in the script.

Related

In App Maker, can you fake valueIsRecord with a dropdown field?

In App Maker, what is the simplest way to achieve the same result with a dropdown box that you can with a suggest box, which can return the whole record when you make a selection giving you the ability to assign associated record values to other fields on the page?
Consider a data model with three fields, (Code, Description, and Severity). Add a dropdown box to select the Code. Have the selection, (probably using onValueChange or onValueEdit), write the selected Code's Description to a label field beside the dropdown box. The Code's Severity will also be used to affect the style in some way like background color or something, but for this answer, merely assigning the value to a scripting variable will be good enough. It's the record value access and assignment mechanism I am after.
Clarification: This data model will not be the page's datasource. It is a secondary reference table used for assigning a code to a ticket. You can also assume that a record value will be written to a field in the page's datasource as well.
I would appreciate the simplest low code solution as we will have non-programmers attempting this. Thanks.
As long as you leave your value binding on the dropdown blank the following should work:
Set the options binding to:
#datasources.YourDatasource.items
You may want to consider changing the 'Names' binding to be the projection of a particular field in this datasource otherwise the values showing in your dropdown will only be the 'keys' from this datasource.
Then in your onValueEdit event you will gain access to individual fields like this:
var item = widget.datasource.item;
item.YourFieldToEdit1 = newValue.YourOtherDatasourceField1;
item.YourFieldToEdit2 = newValue.YourOtherDatasourceField2;
That would probably be the simplest way.

Is it possible to add values to table widget programmatically in Google Appmakers

I am able to show the data source data in google app maker table widget, but I don not know how to show static values (array of object) to table widgets programmatically.
I am new to app maker,I don not know is it possible to add values to table widget programmatically or not.
If any one knows please help me...
Thank you in advance :)
To call your own create children method you would want to set up a panel similar to the picture provided and set a datasource for that panel for which items you want to appear in that panel.
Then go to events for that panel and in the onDataLoad event enter the following code as it pertains to your own data. In my example I used a datasource called employees, and I created a label with the employee name for each item in the datasource.
widget.datasource.items.forEach(function(item) {
var node = document.createElement('div');
node.className = 'app-Label';
node.style.margin = '8px';
node.textContent = item.EmployeeName;
widget.getElement().appendChild(node);
});
That is about the simplest example I have. In the case of a table you would want to create your own base container, a header, and then a container that holds all your table rows. Then in your table body you would set up a similar script that attaches row panels and in the row panels you would create your labels. This would also be possible to declare your own array of objects and loop over each object this way.

Dynamic ajax category child dropdown

I'm using GF to create a filter. Some part of the work is done.
What I need to do now is allow 3 or 4 dropdowns to be populated dynamically.
I'm using the code providade in topic in http://goo.gl/hU31iK
I already made the queries on my table, but I'm having some difficulties, as described below:
First, my form ID is 1.
My first dropdown's ID is input_1_6
Second is input_1_4
Third is input_1_5
Fourth is input_1_7
That said, using the code in topic above, the values for input_1_4 is being loaded after choosing some value in input_1_6, but it isn't actually populating the dropdown input_1_4 (javascript alerts the values loaded, but the dropdown is empty).
Plus, any ideas on how to create the third and fourth filters, based on choices?
-- Field input_1_6 loads
-- Choosing some value in input_1_6 populates input_1_4 (based on value in input_1_6).
-- Choosing some value in input_1_4 populates input_1_5 (based on value in input_1_4).
-- Choosing some value in input_1_5 populates input_1_7 (based on value in input_1_5).
-- Choosing some value in input_1_7 and click submit form will do my stuff.
Thanks!

How to colour a column differently depending on value

I am trying to create a column in a report which would take entries from a corresponding column from the database. This LOV is returning the active or inactive status depending on the value of the base column.
I would like to add colours to this column so it could be easier to spot records where the status has been set to inactive. So, green for active and red for inactive.
Any help greatly appreciated.
IR region source
select * from emp
Made an LOV on deptno
Run the report. Go to Actions > Format > Highlight
On the highlight options you can specify colours, whether to highlight the row or just a cell, and the condition for the highlight. Note that for lov columns you can pop open an lov with the values for that lov through the arrow button next to the expression field!
Applying this will result in this:
If you want this applied by default do not forget to save your report!
If highlighting is not to your satisfaction, you can still go the javascript / CSS way.
Create a dynamic action to fire after refresh of the IR region, with a true action of type Execute Javascript.
$("#apexir_DATA_PANEL td[headers='DEPTNO']").each(
function(){
if($(this).text()=='ACCOUNTING'){
$(this).addClass('deptAccounting'); //great to keep style in CSS!
$(this).css({"background-color":"red"}); //for that quick fix
}
}
);
Note that for this you need to specify the column (headers) and have to code in the to-be-compared text!

Checkboxes and View Based Table View

I am having some difficulty trying to use checkboxes as the selectedIndex in a view based table.
There is good documentation on view based table here:
[View Based Tables ]
However, I after searching and looking on Stackoverflow I can't seem to get my implementation for doing the following.
My view is a table that makes a callout to Yahoo Finance. The table is view based constructed with bindings.
When the table is populated I want to have a check box against each row so that when the user clicks the check box, that row will be updated from Yahoo. Currently this works using multi or single selection using the table view and an observer.. I want to do this with the checkboxes and a button that gets all the checked rows.
The IB setup is as follows:
What is the best way to get the rows where the checkbox is selected? Should I use the array controller or do I need to do something with the table?
Assuming that you use a NSArray of NSDictionaries as your data model, why not add a key/value pair to each "stock" dictionary as a flag? Then in your button action method, just iterate through the data model and trigger an update when the flag is set. Bindings do the rest!

Resources