Xpages Getting Dojo Combo Box to have drop down - dojo

I am writing an Xpage in which the user can create a new document. On field is a category field. I want this field to be a drop down or type ahead with the possible values to be based upon previous entries. The user should also be able to add a new entry.
So this is the equivalent to a traditional dialog list field with "formula for choices" and the formula comes form the first categorized field on a view, with the "Allow values not in list" checked.
I am using a dojo Combo Box, but it displays the values in the field itself, instead of in a drop down.
Not sure what I am doing wrong:
My code is
<xe:djComboBox id="djComboBox2"
style="width:400px">
<xe:this.value><![CDATA[${javascript:var tmpView:String = "tipsByCategory";
var tmpColumn = 1;
var tmpVals = #DbColumn("",tmpView,tmpColumn);
tmpVals}]]></xe:this.value>
</xe:djComboBox>

In djComboBox
property value does the data binding to a document's field or a
scope variable
property selectItems has to deliver the list of possible entries
user can choose from.
Your code should look like this then:
<xe:djComboBox
id="djComboBox2"
style="width:400px"
value="#{document1.yourField}">
<xp:selectItems>
<xe:this.value><![CDATA[${javascript:
var tmpView:String = "tipsByCategory";
var tmpColumn = 1;
var tmpVals = #DbColumn("",tmpView,tmpColumn);
tmpVals}]]></xe:this.value>
</xp:selectItems>
</xe:djComboBox>

Related

Script to access and assign values from a nested object

I have a script (provided below) created to extract and assign values from a nested object to text fields residing on a PDF form. Unfortunately, the script fails resulting in a number of undefines due to what appears to be a Null f value. To clarify, the event.value is a value selected by the user that gets assigned to a combo box on the form. Hence, for whatever reason, the combo box selection is not getting assigned to variable 'f' in which event the script fails and results in undefines for the field values on the form. I am contemplating that the solution requires a minor script adjustment for accessing the objects values. Thank you ahead of time.
var oField = getField("dataSource");
oVendors = JSON.parse(oField.value);
for(j=0;j<14;j++){
f=getField("inf."+j);
f.value = oVendors[event.value][j];
}
Upon further reading and learning about how to create and use a JS
object, the initial script posted was entirely wrong. The script
required to extract and assign values from a JS object to text fields
residing on a PDF form is as follows:
dsFld =getField("dataSrc");// dataSrc is a hidden text field that
resides on the PDF form
oVendors = JSON.parse(dsFld.value);//parse oVendors, a JS object stored
as a JSON string in the hidden dataSrc field
btnDel=getField("btn.del");
var oFld;//declare var oFld for later use
var oPassData = oVendors[event.value];//assign a field value to var
oPassData
if(oPassData){
//walk members to fill form fields
for(var nNm in oPassData){ // skip fields that don't exist on form
oFld = this.getField("inf." + nNm);
if(oFld)
oFld.value = oPassData[nNm]// assign property values stored in
oVendors data object to associated PDF form fields
}
Sorry for my initial post and any inconvenience to the forum.

How to use a combobox in ms Access to display the value of field in table and at the same time present the users with a list of options to edit?

I have an unbound form where my controls (among which there are some comboxes) are filled with data in a DAO.Recordset rst (opened with a SELECT SQL statement):
me.Controls("mycontrol").Value = rst.Fields("somefield")
The combobox displays the correct value ('YES' or 'NO') stored in the table. How can I make the combobox display these two options to the user if he wants to change the value? And how to I get the value the user picked (in VBA)?
Never mind. I think I did it!
mycontrol.RowSourceType = "Value List"
mycontrol.RowSource = "YES;NO"

How to set the default value and read the selected value of a Dropdown Listbox

So I've added a field with the Dropdown type as Listbox via Screen Painter (SE51).
I've binded the data to the dropdown using the PBO and the VRM_SET_VALUES function.
I have 2 problems with this;
How do you set a selected value to the binded data?
How do you get the value selected by the user.
Data is bound to the dropdown using the following code;
LOOP AT it_zzdelay_text INTO wa_zzdelay_text.
wa_listbox-key = wa_zzdelay_text-zz_delay_reason.
wa_listbox-text = wa_zzdelay_text-zz_delay_reason_text.
APPEND wa_listbox TO it_listbox.
ENDLOOP.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'ZZ_DELAY_REASON'
values = it_listbox.
The zz_delay_reason is the unique key and the zz_delay_reason_text is the accompanying text.
Update:
According to your code, the field on the screen should be: ZZ_DELAY_REASON
And you also need a global variant with the name.
Then you can Set/Get key value in PBO/PAI:
Set value:
ZZ_DELAY_REASON = 'KEY'.
Get Selected Value(key):
lv_key = ZZ_DELAY_REASON
======================================================
When select list is set by VRM_SET_VALUES, you may notice it is a "Key-Value" pair. The field "KEY" is filled into the screen field value when the user selects drop box.
I could provide detailed information if you attach your code in this question.
Firstly, several prerequisites are to be met to make a functional drop-down:
You item table should have type vrm_values
Values that are showed in the list should be in field text of the item line. Key should be in field key.
PARAMETER should have type LISTBOX.
After all that is done, answers for your questions would be:
Relation of KEY-VALUE is done via vrm_values type. Each line of this type is an drop-down item, where text is a visible text, and key is key.
Parameter automatically gets the key value after user selects the item in the listbox.
Here is the sample code:
REPORT drop-down.
TYPE-POOLS: vrm.
PARAMETERS p_werks LIKE t001w-werks VISIBLE LENGTH 20 AS LISTBOX OBLIGATORY.
DATA: t_werks TYPE vrm_values,
w_line LIKE LINE OF t_werks.
INITIALIZATION.
SELECT werks name1
FROM t001w INTO (w_line-key, w_line-text).
APPEND w_line TO t_werks.
ENDSELECT.
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_WERKS'
values = t_werks.
END-OF-SELECTION.
WRITE: / 'Selected factory:', p_werks.

Populating a dropdown menu in Visual Basic 2008

I would like to populate a drop down list using values from the database. I would like to know how I can add to the dropdown list both the display member and value member straight all from the database
Display Name: Account_Name
Member Value: Account_ID
Is this possible? If yes, How is it done
Assuming you are binding programatically using a datatable/datareader or similar. Use the DataTextField and DataValueField Properties. e.g.
DropDownList.DataValueField = "Account_ID"
DropDownList.DataTextField = "Account_Name"
EDIT
For a combo box with a datareader you would use something akin to the following
YourComboBox.DataSource = yourDataReader
YourComboBox.ValueMember = "Account_ID"
YourComboBox.DisplayMember = "Account_Name"

dijit.form.Combobox show label Instead of value

I've a dijit.form.Combobox field which uses a ItemFileReadStore to pull Its data.
Teh ItemFileReadStore has two attribute per Item value which will be used for form submission , generally Unique Integers and label which is Human Understandable String.
In ComboBox HTML I've done searchAttr="value" labelAttr="label"
When the ComboBox Shows the list it uses teh label Attribute.
But When the User selects one of the Item it shows the value of that Item.
What I want is , The value Attribute will Still be used for Form Submission. But the User will always see the label in the combobox Control.
alt text http://img822.imageshack.us/img822/6660/dijitcombo.jpg
e.g. I Want to Show The Label for value 3 (Admin) instead of 3
Use FilteringSelect instead of Combobox.
Note: ComboBox only has a single value that matches what is displayed while FilteringSelect incorporates a hidden value that corresponds to the displayed value.
I have tried the following.
var cmbObject = Registry.byId('combo dojo id'); var id =
cmbObject.item.<Code Property>;
You should check if item is null.