Dropdown menu can not save to datasource - google-app-maker

I have two tables (ClientName and PMLprojects), that are related.
I create a form PMLprojects to input data (create), but in the Client_Name field, the options list goes to the ClientName table.
My problem is, I can see options on ClientName from PMLprojects form, but I cannot save it to Datasource.
Main Panel -> PMLprojects
Panel Form -> Inherited PMLprojects
Relation : PMLprojects (many) --- ClientName (one)
Dropdown option : #datasources.ClientName.items
Dropdown value : #datasource.item.Client_Name. (with dot, I can not set only #datasource.item.Client_Name)
Am I missing something ?

Related

Appmaker Input Form, change options based on earlier dropdown choices

Hypothetical:
Say i'm having someone order a cake and they choose vanilla or chocolate, and then they have to choose a frosting
if vanilla: strawberry or buttercream
if chocolate: mocha, dark chocolate or buttercream.
Right now the frosting value in the data model can accept all four options, so all four show up in the dropdown.
a) is there a way to change the binding for the second dropdown after the first is chosen?
This can be done without having the data saved in any datasource. Simply do the following...
Suppose the first dropdown is named primaryDropdown and the second dropdown is called secondaryDropdown. In the primaryDropdown options set the following:
["Vanilla", "Chocolate"]
Also, make sure to uncheck the option allowNull and on the onAttach event handler, place the following:
widget.value = "Vanilla";
Now we move on to the secondaryDropdown. Here, we will do a binding so place the following in the options value:
getAvailableOpts(#widget.root.descendants.primaryDropdown.value)
In the client script, we need to make sure that function exists so please paste the following in any client script:
function getAvailableOpts(primaryValue){
var options;
switch(primaryValue){
case "Vanilla":
options =["Strawberry","Buttercream"];
break;
case "Chocolate":
options = ["Mocha","Dark Chocolate","Buttercream"];
break;
default:
options = [];
}
return options;
}
From here, you are good; However we can still make it better. For that, make sure to also uncheck the allowNull option for the secondaryDropdown and then we need to add some logic in the onValueChange event handler of the primaryDropdown.
widget.root.descendants.secondaryDropdown.value = widget.root.descendants.secondaryDropdown.options[0];
References:
https://developers.google.com/appmaker/ui/input-widgets#dropdown
https://developers.google.com/appmaker/ui/binding#bindings
https://developers.google.com/appmaker/scripting/client#use_scripts_in_binding_expressions
Im guessing you set the dropdown "possible value" options in the data source and you have those fields as just string fields in your table.
the quick and dirty way to do this is go to the Cake drop down and on the Property Editor>Events>OnValueChange select Custom Action and use this Code
if(widget.value==="Vanilla"){
widget.root.descendants.Field.options = ['Strawberry','Buttercream'];
}else if (widget.value === "Chocolate"){
widget.root.descendants.Field.options = ['Mocha','Dark Chocolate','Buttercream'];
}
"Field" here is replaced with the name of the dropdown box for your frostings
also go to the property editor of the frostings dropdown and delete everything in the options field there.
I was trying to solve for a similar situation and created an additional table to serve as a lookup.
I have a drop down for CATEGORY with possible options set on the field in the main data source.
Then I have a second table with 2 Columns: CATEGORY, and SUB_CATEGORY.
On the entry form I have options for the SUB_CATEGORY drop down set to SUB_CATEGORY on the CATEGORY_MATRIX lookup table.
Then for an onValueEdit event on the CATEOGRY drop down I have a script to reload the CATEGORY_MATRIX table source based on the value of the CATEGORY drop down in the query so when the CATEGORY is selected only valid SUB_CATEGORY options are shown in the second drop down.
var datasource = app.datasources.CATEGORY_MATRIX
datasource.query.filters.CATEGORY._equals = newValue;
datasource.load();
There may be more efficient ways to do this but the benefit is I could create another form page and dynamically add new combos so there isn't any required code change as new combos are needed.

IBM Notes editable fields getting data from parent form

In Notes I have a form (Order) in which I have button "Create new OrderLine" which creates a new form(Orderline). The Order document has an embedded view on the design which gets orderlines documents. Each orderline document contains a hidden field with the ID of the order document, so that you know which orderline is connected with which order. Same goes for Orderline this has an embeddedview with Prices.
In the Order form I have 2 editable text fields: AdministrationNumber and DebtorNumber.
In the OrderlineForm I only got the debtorNumber
In Prices I have a editable number field called Fee.
So I did this on various ways:
In the postOpen of the form prices I have put this LotusScript code:
If( (Source.FieldGetText( "AdministrationNumber" ) = "1" ) And (Source.FieldGetText( "DebtorNumber" ) = "2") ) Then
Call Source.FieldSetText("FeePercentage", "4.235")
Call Source.Refresh()
End If
But did not work.
In Default Value of Fee I also tried this formula code:
#If((AdministrationNumber="1") & (DebtorNumber= "2");
"4,235";
"0"
)
But also of no use..
Is it possible for an editable field to be set when opening the subform based on conditional statement with data which is in the parent form?
Edit
2 ways to solve:
1.
When clicking "Add new Orderline" Button whic is on the Order form, I will call a function in the scriptlibrary, in this function I get values of debnr and admnr and then do the conditional statement.. If true then set FeePercentage
2.
Added new hidden field on the orderlline called admnr which gets the administratorNr field data when the New Orderline Button is clicked.. The field is set through a function in the scriptlibrary.
Eventually in the postOpen of the prices subform this works:
Dim doc As NotesDocument
Set doc = Source.Document
If doc.admnra(0) = "1" And doc.debnr(0) = "2" Then
doc.FeePercentage = 4.235
End If
Work with back-end classes instead:
Dim doc as NotesDocument
Set doc = Source.Document
If doc.AdministrationNumber(0) = "1" And doc.DebtorNumber(0) = "2" Then
doc.FeePercentage = 4.235
End If
It gives you easy access to all fields in document.
You say "subform" which has a special meaning in Notes design but it sounds like what you have is a form called "Order", a form called "OrderLine" and a subform called "Prices" that the OrderLine form uses?
In which case, make sure the OrderLine's the "Formulas inherit values from selected document" form property is checked.
That and your default formula should do it if the button is on the parent form (as opposed to view the Order form embeds).
P.S. You might want to change your default formula to
#If(
(AdministrationNumber="1") & (DebtorNumber= "2"); 4235;
0
)
so that it returns a number instead of text that looks like a number.

NSTableView set column to disabled

I have a NSTableView tied to a NSArrayController. The first column are checkboxes. I want to have the users select the rows to perform an action on via the checkboxes and when the user clicks the "Run" button I want to set the state of that column to be un-editable.
How do I go about this?
Thanks!
rather than disabling the column I disable the individual checkbox cells in my app based on a global app state.
Preconditions:
1.) your "Run button" sets some sort of a global state in your controller class. For me its a "Play" button that sets a member in my controller like:
if ([self gotoNextSong])
_currentPlayMode = PLAYMODE_PLAY;
else
_currentPlayMode = PLAYMODE_STOP;
2.) Your controller is already a delegate to the NSTableView. If not:
In your MyController.h:
#interface MyController : NSObject <NSTableViewDelegate>
In your MyController.m make your controller to a delegate of the table - e.g. in your init: method
[self.myTableView setDelegate:self];
3.) You know the identifier of the column that holds the checkboxes. If not, either its the automatic name like column1, column2, ... or you can set it in Interface Builder while the column is active in Identity Inspector / Identity / Identifier. In my case the column name is "checkboxes"
Solution:
1.) Add a delegate method for the table to inform you when the cells are rendered. Inside this method enable or disable the cells of the checkbox-row as desired
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn: (NSTableColumn *)aTableColumn row:(int)rowIndex
{
if(([[aTableColumn identifier] isEqualToString:#"checkboxes"]))
{
if (_currentPlayMode == PLAYMODE_PLAY)
[aCell setEnabled:NO];
else
[aCell setEnabled:YES];
}
}
2.) Make sure that your RUN-button not only sets the global state (in my case _currentPlayMode), but also force the NSTableView to redraw afterwards:
[self.myTableView setNeedsDisplay:YES];

format databound field according to the value- ASP

I have a data bound field say "Role"
The values in the database for its corresponding field contains 1,2,3.
I need to know whether i can format that databound field according to the value
for eg:
if 1 is the value, it should show "Admin".
if 2 is the value, it should show "Support".
if 3 is the value, it should show "User".
can i use DataFormatString for this purpose??
PLS HELP.
One approach is get this value before you display it e.g from database or codebehind
Select
Role,
CASE
WHEN Role = 1 THEN 'Admin'
WHEN Role = 2 THEN 'Support'
WHEN Role = 3 THEN 'User'
END RoleDescription
FROM MyTable
Output is below. You can use the RoleDescription value instead of Role
Role RoleDescription
----------------------------------
1 Admin
2 Support
1 Admin
1 Admin
3 User
Atlast i found a WAY.. anyways thanks codingbiz!!
Make that field as a templatefield and edit that template. In the item template view, remove the label field and insert a dropdown. there you manually add the items with its values and bind selected value to the field (here role).
steps..
Select item > convert it to TemplateField >
Edit template > select that template (ItemTemplate) >
Change label to dropdown > add items to drop down with its value > bind selected value property to the original data field..
THATZ IT!!

Unable to mark SelectListItem as selected (ASP.NET MVC2)

I have a SelectList in my MVC2 model.
In the case that there's only 1 item in the SelectList I want this one item automatically selected (in my view I add an additional item).
My problem is that I can't get this single item to be selected.
So the class behind my model has
if (Clients.Count() == 1)
{
Clients.First().Selected = true;
}
But immediately after stepping through this line, if I add a watch to Clients I can see that Selected = null.
In addition, on my View I have
<%:Html.DropDownListFor(c => c.Client, Model.Clients, "-- Select Client --") %>
When the page loads -- Select Client -- is always selected.
Can anyone explain how I can get the model to correctly mark the item as being selected?
Your view model must have a property Model.Client and it would appear (from the code above) that you're not setting that value?
Perhaps in the controller action:
Model.Client = Clients.First();
It's the Model.Client property you need to set though, not the SelectList options.

Resources