To Whom It May Concern:
I have a Dropdown list that populate a Text Field based on below code:
TextField.rawValue = Dropdownlist.rawValue
The user is Allowed Custom text Entry.
What I need is if the user adds his own text the textfield.rawValue should be empty
So far I have the follow script:
If (Dropdownlist.selectedIndex == Dropdownlist.selectedindex)
TextField.rawValue = Dropdownlist.rawValue
else
textfield.rawValue = "Empty"
endif
if I run this I get on the textField the value of "Empty" although I have selected a value that has a specific value assigned.
Your assistance is appreciated
That is in FormCalc and I work in javascript but the issue is in the logic, not in the syntax.
In your current setup the if statement condition will always evaluate to true - Dropdownlist.selectedIndex will always equal itself.
However, if the user has entered a custom value then the selectedIndex for that dropdown will be -1, so you can test for that.
Use this condition instead in your If statement:
(Dropdownlist.selectedIndex <> -1)
Related
[google-app-maker]
New to AppMaker and never done coding before, so please excuse the question if obvious or I'm trying to do the impossible.
App Maker -
I have a page,
on the page is a 'Create' Item form,
and then on another panel on same page, a dropdown from another model thats generated from a 'one relation end' and using a none related datasource or model to the model I am updating.
Like me my code is very simple(as learning) Im just trying to update a field within the model the form is creating a new item in with the current dropdown value, that comes from a different datasource and based on a 'one relation end' from two other tables.
Table:
Id | date | action | user | note | theValue |
'did it' X
I have applied the code within my 'Submit button' on the form, to keep it very basic.
widget.datasource.item.action = 'did it'; // Works fine
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value; // this fails ( error below )
widget.datasource.createItem();
But I get the following error.
ERROR --
Type mismatch: Cannot set type sites record for property newValue. Type String is expected.
at assets_move.Content.Form1.Form1Footer.Form1SubmitButton.onClick:2:33
I can see by the error, its not passing as a string, not sure if this is because its a dropdown with a different datasource on another panel, or Im using the wrong binding to get the value.
Any help much appreciated.
The problem is likely that the value binding you have in the property editor of the Sites_dropdown widget is not a string, make sure it is a string binding and it should work. Also, with a binding, you will not need this anymore:
widget.datasource.item.theValue =
widget.root.descendants.Sites_dropdown.value;
Since the binding will handle that for you.
You may also have the Options property of the widget set to a record, and thus the value is also a record. Make sure options is also a string and not a record.
I have a model with two fields, Name and Token. In my app, the user will select a record from a Dropdown populated with the Name field of all records. When this happens, I need to assign the record's corresponding Token value to a variable in a server script, but am not sure how to accomplish this.
There are two options that are suitable. As a first option you could implement a server script that returns the token of the field when you edit the widget.
function checkToken(widgetValue) {
var query = app.models.YourModel.newQuery();
query.filters.Field._equals = widgetValue;
var records = query.run();
return records[0].Token;
}
You can add the script caller checkToken(widget.value) to the onValueEdit event of widget, so that it runs every time you select another dropdown item. If you want to use another event, please look at https://developers.google.com/appmaker/ui/logic#events.
As a second option you could add a secondary label to your form which you bind to the dropdown item selection. The binding would look something like this:
#pages.MyPage.descendants.DropDown.value.Token
When you configure Dropdown you need to set three important properties:
options
An array of string representations of options that makes up the content of the dropdown
#datasources.MyDatasource.items..Token
names
An array of strings to be displayed in place of options' default strings. The array must be the same length as options.
#datasources.MyDatasource.items..Name
value
The value assigned to the databound property, based on the user's dropdown selection
// Assuming that dropdown is added to form
// or any other container bound to proper datasource.
#datasource.item.Token
Note
double dot .. syntax is used for projections
I wonder in visual studio, what would be the code to acquire the value from the Checkbox. Say, if checked, value=1; if not, value=0.
I know for radio button, I can automatically assign the value. But what about the checkbox? Do I even need to register a user control and write a case function such as
_checkResult = value
Select Case _checkResult
Case 1
CheckBoxA.Checked = True
Case 0
CheckBoxA.Checked = False
End Select
Much appreciated for any help:)
To get the value of a checkbox all you need to do is call Checked.
Your code is doing something different though. You are setting the value and a case statement correctly works to do this as long as value is restricted to being either 0 or 1. I would recommend to use a boolean datatype for _checkResult as this ensures that it will always be set. It also makes it easier to set the value as shown below.
CheckBoxA.Checked = _checkResult
I'm trying to implement multiple record selection feature on a grid.
It is very similar to http://www.tek-tips.com/faqs.cfm?fid=3831
It adds an extra column with check boxes. I want those check boxes!!
But it depends on a extra logical field in the underlying table. It need to create a class clscheck which inherits CHECKBOX. I'm not sure why this CLICK procedure is needed for the checkbox.
PROCEDURE CLICK
IF DODEFAULT()
KEYBOARD '{DNARROW}'
ENDIF
ENDPROC
When I removed it, row selection did not work correctly as expected. Why this?
Here is my requirement:
1) I don't want to add an extra logical field in the underlying table.
2) To work with controls in the grid, I think AllowCellSelection must be .T. I want AllowCellSelection = .F. because I don't need to work with any control in the grid except the check boxes. I need to work only with check boxes. The other columns will be read-only.
3) Can I have selected list without the logical field in the underlying table?
4) Can I remove the usage of KEYBOARD '{DNARROW}'?
In fact, I have a grid which is AllowCellSelection = .F., but it only provides single selection.
I need to enhance it with multiple selection, thus, I just want to add an extra column with check boxes so that user can know he can select multiple records.
No need Shift+Click or Ctrl+Click which is not familiar with idiot users.
I have found this - http://www.tek-tips.com/faqs.cfm?fid=433
It also depends on an extra logical field and it depends Shift+Click and Ctrl+Click.
What you are seeing is quite common for multi-select grids. I've used them SIMILAR to this in the past. However, you are afraid of the extra column in the underlying table. That may/not be true. You don't always have to update the ORIGINAL table, but a temporary CURSOR you are presenting to the user. Ex: If you want to display a list of employees in a table. No, you don't want to keep adding this column to the original employee table as then anyone else trying to do multi-select could falsely get your selection. However, if you pulled into your own local cursor and presented to the user, then no problem. Example...
Thisform.YourGrid.RecordSource = "Employees"
(bound directly to your employee table -- not necessarily the right thing)
vs
use in select( "C_MultiPickEmployees" )
select ;
.F. as IsChosen, ;
E.* ;
from ;
Employees E;
into ;
cursor C_MultiPickEmployees READWRITE
Thisform.YourGrid.RecordSource = "C_MultiPickEmployees"
NOW, you have your extra column without dealing with issues to the underlying table. If you wanted to further filter what you were showing -- such as employees for a certain division/department, then just add that to a WHERE clause, add an Order By if so needed and you are good to go.
As for the "Allow Cell Selection", I've never had to deal with that. I just add a "checkbox" to the first column and set
Thisform.YourGrid.Column[1].CurrentControl = "CheckBoxControl"
(based on the name it is added to the column).
Then, set the column 1's "ControlSource" = "C_MultiPickEmployees.IsChosen" and you should mostly be done.
As for the "CLICK" event trying to force the down arrow. This is more for automatically scrolling to the next record so you can just click, click, click for multiple entries.
Hope this helps clarify things for you.
There have an error
"Object Reference not set to an
instance of an object"
when using objusername.intuserid=listbox1.selecteditem.value.
Check if listbox1.SelectedItem is null, or listbox1.SelectedIndex = -1 before accessing the property. This basically means nothing is selected.
Your ListBox1 can also return Text using SelectedValue property iff value has set to that before. But above is more effective way to get text.
Now, the value is something that is not visible to user but it is used mostly to store in database. We don't insert Text of ListBox1, however we can insert it also, but we used to insert value of selected item. To get value we can use
ListBox1.SelectedValue