Is there a way to access the fields of a record, selected by a radio button widget in Google App Maker? - radio-button

Summary
I am fairly new to AppMaker and this question centres on hierarchies. I have a Taxonomy table with a straight forward parent has children hierarchical relationship.
TaxonomyGroup -> has many Features -> has many Values
I've been working on a way to traverse this hierarchy using tile/grid widget.
When I reach the last node of the tree-structure I display this as a set of radio-buttons, representing the permitted options.
Example
Starting group is: Car
a Car has the following features:
-Colour
-Red
-Blue
-Silver
-Green
-Transmission
-Automatic
-Manual
-Fuel
-Petrol
-Hybrid
-Electric
If the parent group was Motorcycle, I would have a different set of features and options (permitted values).
A user selects the following for a Car:
+Colour
-Silver
+Trans
-Automatic
+Fuel
-Electric
Issue
While I can capture Silver, Automatic, Electric as the options selected, I cannot pick up the ID or any other fields of the record represented by the radio button selected.
Grid widget set-up
Taxonomy Grid Panel..... parent layer DS = Taxonomy (table) Id In [list]
Taxonomy Grid Child panel 'child' layer DS = TaxonomyChildren, ParentId = :parent
Radio button list DS = TaxonomyChildren: SubGroups (relation)
NB the radio button list sits within the Taxonomy Grid Child panel, so the list of options changes, based on the feature.
Radio button code onValueEdit event
// provides the row index of the selected Feature. e.g 'Transmission'
var rowIndex = widget.root.descendants.TaxonomyChildGridPanel.selectedIndex;
if (rowIndex === 0 ){
widget.root.descendants.Feature1.ID = widget.datasource.item.Id;
} else if rowIndex ===1 {
widget.root.descendants.Feature2.ID = widget.datasource.item.Id;
}
: //etc etc
}
Radio button widget issue
widget.datasource.item.Id
returns only the ID for the 1st item in the radio button list.
E.g. record ID 117 representing the option 'Petrol' not Electric as the radio button option selected.
I need to be able to capture the record behind the radio button selection, representing the node (called values) of the tree structure. In particular the ID of the record. Then store it against the creation of a new record, in this example a new Car record.
At present: onValueEdit event: the wrong record_ID is provided and it is always the 1st option in the radio-button list, irrespective of which option was chosen.
Screen shots
Grid panels for hierarchy levels 1 & 2, Radio buttons represent values
Hierarchy view with data

For this question resolution, see the answer given to the following question:
[How to obtain the record ID of the selected item in a dropdown list in google app-maker
Namely: onValueEdit event for the radio button selection the record id can be obtained using newValue. For Tick Boxes, it is newValues which builds an array of answers based on the items ticked.
if (!newValue) {
return;
} else {
answersDS.query.parameters.answerListIDs.push(newValue);
answersDS.load();
}

Related

How to obtain the record ID of the selected item in a dropdown list in google app-maker

Summary
Obtaining the record ID of the selected item in a drop-down list or radio-button UI appears to be a common question, but I have not found the answer for Google AppMaker despite months of searching.
The example use case: is I wish to edit a product that belongs to a family:
Product - (N:1) --> Family
Product - (M:N) --> FeatureValues
Example
The product belongs to the family Credit Card.
The credit-card family has the following features: |Contactles
|Near field
|Rates
|Chip & Pin|
In the edit form if I change the family the product belongs to then the list of features will change and new values for the features will need to be entered. (Dynamic form)
Hierarchy table
The family, features and permitted values are held in a single hierarchy table:
Family
|
Features
|
Values
newValue._key appears to only work for text-box UI items.
Dropdown list:
widget.datasource.item.Id or _key
provides the Product ID of the parent data source, ProductById (because I am editing a single product)
widget.datasource.selectKey(newValue._key); returns undefined
Sample code
Drop-down-list
OnValueChange event:
//update the features drop-down based on the taxonomy family selected
app.datasources.TaxonomyChildren.query.parameters.parent_fk = app.datasources.TaxonomyFamilies.item.Id;
app.datasources.TaxonomyChildren.load();
If I can pick up the record ID for the selected family in the dropdown list I can set a query.filter.parameter to show the features and values for the newly selected family.
Note: if it is a case you cannot create 'dynamic' forms in Google app-maker, then I'll stop as this has exhausted a lot of time.
Markus wrote:
So leave the options and value settings but in the onValueEdit run your query against TaxonomyChildren by passing in newValue.id to the query
Great Markus, that worked. On the drop-down ValueEdit event I call the function loadTaxonomyChildById(newValue.Id); passing it the Id of the selected TaxonomyFamily, changing the features displayed.

RowFilter on JFace TreeViewer

I have a TreeViewer as shown here:
.
I have a text field to enter the percentage values. Suppose the percentage entered is 30 %, I should hide all the rows that are below 30% and display only the rows above 30%. Is there any row filter that I can use for my TreeViewer? It would be great if some examples are provided.
I am using e4 RCP. I want to do View based filtering and prefer not to change the Model.
You use a class which extends ViewFilter to filter the rows in a tree viewer.
The main method to override in the ViewFilter is the select method:
#Override
public boolean select(Viewer viewer, Object parentElement, Object element)
here you are given the object being considered (element) along with its parent and the viewer. You return true to keep displaying the element and false to hide it.
You can have several filters active if required, set them in the tree viewer using:
treeViewer.setFilters(array of view filters);
You may need to call
treeViewer.filter();
when something changes in the tree which requires the filters to be re-run.

TableView delete column via contextual menu

It is my first time asking here, sorry if i do something wrong (also not in my mother tongue).
Recently, i moved from Swing&AWT to JavaFX.
I am discovering the new Table which is quite different from the Swing version. Better i would say, it needs less operation and do more things, but ... lord, it's way more difficult to understand !
I am currently trying to modify the TableView dynamically. While the addColumn method is not a big challenge, i need help for my deleteColumn method :/
Let's talk about my problem :
I have a scene with many components on it (panes, buttons, menus, ...) and one pane (actually an anchorpane) hosts a TableView.
I would like to dynamically delete an entire column when this operation occurs :
The user right clicks on the TableView > a contextual menu shows up > he selects the item "delete"
So, basically a contextual menu that offers the option to delete the column where the user right-clicked.
I tried this :
-> When the user right-clicks on the TableView, this method is called :
public void setTargetForContext(ContextMenuEvent event){
if(event.getTarget() instanceof Label){
ObservableList list =(((Label)event.getTarget()).getChildrenUnmodifiable());
activeColumn = ((Text)((ObservableList)list)).getText();
}...
And the goal was to set the column name in "activeColumn".
Then, when the user will select the "delete" option from the contextual menu, another method would be called to compare the name of the columns and delete the right one.
But it seems that i can't call a getChildren() method on the label, only an unmodifiable one. And it does not allow a cast and throw the exception.
Do you have a solution to allow me to get the column name ?
Or maybe i am going the wrong way and i have to find another way to delete the right-clicked column, but in this case i will need your help too.
Thanks a lot for reading, and thanks in advance for your help.
First, let me point out that if you call
table.setTableMenuButtonVisible(true);
then the table will have a built-in menu button with radio buttons allowing the user to select which columns are displayed. Maybe this is all you need.
In Swing, the renderers for table cells are just "rubber stamps" that are painted onto the table. Thus you can't register listeners for UI events with them.
By contrast, in JavaFX, the cells in a table are real UI controls with full functionality. This means there's no real need for API that gets the cell coordinates from a table. You should not register your listener with the TableView, but with the actual cells on which you want to operate. You access the cells from the table column's cell factory.
// the table:
TableView<RowDataType> table = new TableView<>();
//...
// A table column:
TableColumn<RowDataType, CellDataType> column = new TableColum<>("Header text");
// A context menu for the table column cells:
ContextMenu contextMenu = new ContextMenu();
MenuItem deleteColumnItem = new MenuItem("Remove Column");
deleteColumnItem.setOnAction(e -> table.getColumns().remove(column));
contextMenu.getItems().add(deleteColumnItem);
// Cell factory for the column
column.setCellFactory(col -> {
// basically a cell with default behavior:
TableCell<RowDataType, CellDataType> cell = new TableCell<RowDataType, CellDataType>() {
#Override
public void updateItem(CellDataType item, boolean empty) {
super.updateItem(item, empty);
if (item == null) {
setText(null);
} else {
setText(item.toString());
}
}
});
// add the context menu to the cell:
cell.setContextMenu(contextMenu);
return cell ;
});
If you want the context menu to appear in the table column header as well, you just need to do
column.setContextMenu(contextMenu);

how to get child properties of the div object for rational functinal tester

in my application i have a dropdown which is div object.the dropdown contain names and checkboxes.i need select the checkbox based on name. checkbox dont have any name.just index.can any one suggest how to get chaild items or properties of the objects for div object.
and the second question is i have tree view .which is teleric object.RFT is unable to find the object.it identifying as one all tree view is one object.its not identifying the childs,sub tree items....
so please help me on this two issues.
Hi you can get the checkboxes as follows:
void getCheckBoxes(TestObject parentDiv)
{
TestObject[] checkboxes = parentDiv.find(atDescendant(".class","Html.INPUT.checkbox"));
System.out.println("Found " + checkboxes.length);
//Go through them , and decide which one to select.
for(TestObject checkbox: checkboxes)
{
System.out.println("Checkbox Value: "+ checkbox.getProperty(".value"));
}
}
you can call the above method and pass it the parent DIV object.
About the second question:
You have not mentioed how does RFT recognize the one object for the tree ( means which proxy does it use as per the object map's adminitrative properties for that object).
Usually controls like tree /grid etc are recognized as one control and the items of these controls as "Subitem" which are found by specifying subitem as atPath("xyz->abc") etc.

Does mvc 4 application need another model to return aggregate data on an existing table and model

I have a table (and model) with the following properties in an asp.net MVC 4 application:
TV Table
height
width
depth
type
brand
cost
When the user answes a question about the space that they have for the TV I then do an ajax call to determine which types are possible to fit into the space they have specified. Which type of TV type they want is the following question, so some options may need to be disabled. The SQL for what types fit in the space is "select distinct type from TV where height < #height and width < #width and depth < #depth".
Should I:
1. create a new model that I call from the TV controller just to return the distinct types
2. add a method to the TV model that I call from the TV controller that just returns a list of string with the types that fit
Depends on what you want to display to the user based on her selection' e. g.
If you want to display TV name + its description then returning a list of TV model will make sense.
If you are just going to display a list of TV names in combo box, then returning a list of string will suffice.
Calling a new action make sense in both cases IMHO.
EDIT:
For 2 - I want to return a list of string - should I create a new data model for this, or add a method in the existing TV data model that returns a list of string?
To expand on above query, since its not clear (at least I do not visualize it) from your question i will assume few things.
Case 1: You are displaying a view say "TVSelection" to the user that does not contain list of TVModels. In this view you are expecting user to enter three values i.e. Width, Height, Depth. Now when user enter these values, she can submit the form or you can fetch the TV Brand name list on Lost Focus event as well. In any case, the question would be are you updating existing view by populating the combo box or you are displaying a new view. I am assuming you are updating existing "TVSelection" view by the means of making an AJAX call. In that case you can just call a method on your controller (which displayed the "TVSelection" view) that returns a list of TV Brand names.
Case 2: You are displaying "TVSelection" view that already has a list of TVModel objects and you update it dynamically on selection of required field (filtering). In this case you can add a method in the TVModel itself to filter names only that matches the user selection.
I found these links relevant 1 & 2.
Hope that make sense.
Please add more details to your question if this does not answer your question.