I am using org.eclipse.swt.widgets.Combo which is not read only, meaning a user can insert any string or may select from the dropdown box.
But when I bind it to my model class property I get Null Pointer Exception whenever I am entering any text which is not present in the combo.
databindingContext.bindValue(WidgetProperties.singleSelectionIndex().observe(ComboReporterId),
BeansObservables.observeValue(Model, TextReporter_M));
Please help on this issue.
For a Combo where text can be entered you will need to observe the text:
IObservableValue targetOV = WidgetProperties.text().observe(combo);
You will have to bind this to a value that is a String (or use a Converter).
Related
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 would like an Unbound combobox located in the header of a form to match or filter by any character (s) that a User inputs. I would like those matches only to display in the combobox itself. Once the User selects one of the choices have the form go to that selection and reset the combobox to a complete list.
I tried a parameter query, but that only works once and does not reset. I also looked into LIKE and CONTAINS , but have had no luck.
Use the following in the combo RowSource property:
SELECT [Value for combobox list] FROM tbl WHERE [Value for combobox list] LIKE '*' & forms!MyForm!txtInput & '*'
You need to do cmb.Requery at some stage after a change is made in txtInput. If you do it on the txtInput_OnChange event, you will need to access the Text property of txtInput, so you would need to change the above SQL slightly.
Simplest would be to have a button to be pressed after typing in the filter and putting the Requery method in cmdFilter_Click event
This has gotten me completely frustrated
I have a few webcombo boxes that are hierachial:
Continent
Country
When the form loads everything works fine, when I change the continent the first time, the country repopulates correctly. However if I change the continent a second time I receive an error:
Specified argument was out of the range of valid values.Parameter name: The DataValueField of ValueField was not found in the Columns collection.
Can anyone tell me why?
P.S. This is all I have in the Page_Load event
if (!IsPostBack)
{
this.Load_AreaList();
this.Load_AreasOfInterest();
this.Load_Degrees();
this.Load_GenderList();
this.Load_ParticipationDateModifiers();
this.Load_ProgramCategories(nEventID);
this.Load_YesNoList();
this.Load_ParticipantInformation(nParticipantID);
}
Also this happens in another part of the form with another Country webcombo which is supposed to populate a state combo box.
In many cases, columns in database tables return null when no value is stored in that column. However, a null value can present challenges when you are working with ASP.NET code or with data-bound Web controls. For example, an exception is thrown if you try to bind the SelectedValue of a DropDownList control to null. If this is not the case change AppendDataBoundItems property. The AppendDataBoundItems property allows you to add items to the ListControl object before data binding occurs. After data binding, the items collection contains both the items from the data source and the previously added items.
Let me know if it works...
s
Context:
I am implementing a flex auto-suggest combobox - as the user types in each character: Consider the string 'Stackoverflow' and user input = 'st'
1) the data provider is filtered to show all items starting with 'st'
2) text is set to auto-suggest string such that the un-typed part is highlighted.
So for instance, the combobox text may contain st'ackoverflow', where 'ackoverflow' is highlighted using setSelectedIndex()
Issue:
When I hit back-space or delete, and check the 'this.text' value, I expect that the last un-highlighted character ('t' in the above case) gets deleted and the data provider is filtered to show all items starting with 's'. However the text property contains 'st', as before
Question:
what am I missing? What else can I try out?
I realized that my assumption was incorrect - when I hit backspace, the highlighted portion of the text alone should go away - I need to do some extra processing to get one extra character at the beginning to go away
Here is how this was implemented: Listen to the backspace key event and set a Boolean flag.
Then in the List change handler, read the boolean flag and set the this.text to what you want (i.e.) with 1 char deleted beyond the beginning of the highlight. Note that you cannot immediately set the this.text in the backspace handler because the textinput control backspace handler will reset what we set.
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