Filter and Bind a Multiselect - google-app-maker

I am trying to implement a Many-to-Many relation between a class and its students in a form.
The form can be used to create or edit a class. Also students can be added to that class. To reduce the effort needed to enter students, I would like to add a multi-select that shows the entries from the students-table. But since the number of students is expected to be large, I would like to filter this multi-select.
I checked this question on filtering lists and the sample app "Project List. I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains and set the tables datasource property to STUDENTS
But, as I understand it, a multi-select element's value property must be bound to #datasource.item.students and its datasource property must be CLASS in order for the auto-saving to work.
Hence I wonder whether it is possible to filter a multi-select element.

I don't see the problem, but I think I see a misunderstanding.
You said: "I understand that the standard workflow with a table would be to bind the value of a search box to the #datasources.STUDENTS.query.filters.email._contains"
You need to bind the OPTIONS (not value) to the datasource query, as it is the options that will draw its records from the #datasources.Students.query datasource.
You can then set the VALUE of the multi-select widget to #datasource.item.students (where you want selected values from the student query options to be saved).
You will also need to set the NAMES property (since the options are likely student records). Names will be the Student datasource projection of whatever string field you want to appear in the options list.

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.

Populate Multi-Select widget names from related values

I have a multi-select widget bound to a table that only contains relations. I want to use the related values for each record to populate the multi-select name.
Parent-Table
- Child-Table-One
- Child-Table-Two
No matter which way I try using the multi-select name paths, only the first record name in the multi-select gets populated with the related value from the related child table, the others just display the record ID of the Parent Table.
Do I need to use a function somehow to iterate through all records to get the related values for every record?
Binding to the Relation should get you a list of records. Assuming you're trying to get list of the display names, this should work:
(#datasource.item.Child1).concat(Array.from(#datasource.item.Child2))

How to find object with Missing label?

I have a requirement where I need to create a list of all missing labels in any particular object.
For example.
I want to create a new table with a couple of fields and an overridden method. Now, suppose I am setting up the table property label as "Car details" similarly I am creating new fields and setting their label properties as "Car" and "Model" respectively and overriding validateWrite method with the error "Car-model combination not valid". But, I am not creating a label for any one of them. So now I want to write a job which will show that I need to create three missing labels.
I know Best practice check will give me warnings for the above scenario but I need it as a list as I'll use this list to enhance the Label editor.
Thanks in advance.
You could loop through the AOT using the TreeNode class and select elements where the label property is blank. Then you can send the information out to the infolog or whatever you wish.
There are numerous code examples out there of how to do that, such as this one looping over forms selecting on the HTMLHelpTopic property.

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!

Gridview: column with different controls is different modes

Here is my scenario.
I have an objectdatasource-bound gridview where i want to show Students {name, age, class}
name:string, age:int, Class:Foreign key, int
I also want to edit it, but when doing so i want to show a dropdownlist for the class field.
Currently i solve this by
a)creating a view, binding the grid to that view
b) on the editItemTemplate, put a DDL and bind it to the Class table.
What i want to know is if there is a way without involving the view shortcut.
NOTE: this question, Bind column to a different entity source than the gridview is
is somewhat related, but not quite the same thing. in that example, the OP just wanted to show the related data. Since am also updating, i need both the key and the value.

Resources