ComboBoxFormItem default value
My display form has a combobox. Initially it should not present the user with "Select a value ..." but it must show the actual value of a domain attribute of the selected feature. The possible values come from a domain table (2 columns: Code=integer, Description=string).
I know how to pre-populate other FormItems (like TextBox) using .DefaultText. The ComboBoxFormItem does not have this property. How do I pre-populate a ComboBoxFormItem ?
-
Unfortunately the DataItems property of ComboBoxFormItem is read-only, but you can populate this with dynamically created data by a different method.
You'll see that when you add a ComboBox to a form, there is a 'Input Data' field created on the DisplayForm Task in Workflow Designer. You can create your list of DataItems before presenting the form, and then put your IEnumerable<DataItem> variable in this box. The combobox will then be prepopulated with the contents of this variable.
0 -
Jonathan, thanks for your reply. But it is not exactly what I was looking for. What I want is to set the selecteditem in the combobox. Suppose the possible domain values are: 0=No, 1=Yes. Suppose the current feature attribute has value 1. In the attribute form the attribute value should show "Yes". So, the question is: how to set the selecteditem in a combobox.
I am confused about the meaning of the 'Input Data' field. What is the difference with using the Query Details in the combobox designer.
0 -
I'm afraid that you cannot set the default item for a dynamically generated list of DataItems. By default in this case the combobox will have no selected item, and one must be chosen from the list. This cannot be altered through the 'RuntimeModifications' section, as the combobox dataitems have not been set at this point.
If the values you are using never change, then you _can_ hardcode the dataitems into the combobox in the Form designer, and in this case the first in the list will be the default selected item. It sounds like in your case though you would like the default to change based on the selected item, but unfortunately this is not possible.
The idea behind setting the dataitems using the 'Input Data' is that you can vary the items presented in the combobox based on events (queries, user actions, etc.) that take place elsewhere in the workflow. For example, if one type of feature is selected, you could show a different list of dataitems than if another type is selected. You can prepare the list beforehand and populate the combobox with it, you just can't set a default item this way.
For example if you placed this code in the 'Input Data' box:
new List(of DataItem) From { new DataItem("No",0), new DataItem("Yes", 1) }
It would create a DataItem list that would provide a dropdown populated with your sample domain values.
0 -
I am using Geocortex Essential 3.14 and Silverlight Viewer 1.9, and according to the documentation, this version include the ability to set the default value(s) of ComboBox and ListBox form items with runtime modifications. However, it is not working as expected.
This is what I have done so far:
- Declare a variable dataItemList = List<DataItem>
- Use a QueryTask and FeatureSetToDataItemList to populate the List<DataItem>
- Pass the List<DataItem> into a Display Form as Input Data
- In RuntimeModifications, Assign form.Find(Of ComboBoxFormItem)("ComboBox1").Selecteditem = dataItemList(0)
Can anybody confirm whether this is how it should be done?
I have also tested and can confirm using form.Find(Of ComboBoxFormItem)("ComboBox1").SelectText will 'set the text that will be shown as the first item of ComboBox'. However, it is not setting an existing value in the list, but insert a new entry at the top of the list.
We are relying on the combobox for a casscading query, therefore the selectText is not enough for our requirement.
https://resources.geocortex.com/essentials/apis/silverlight/Reference/Build/Default/topic2662.html
0 -
Hi Mary,
Try form.Find(Of ComboBoxFormItem)("ComboBox1").SelectedValue = "Some Item value in dataitem list". This will select the item in the combobox if it exists in the data items.
SelectText is what displays as a default prompt on a new form like "Select One" or "Choose your favourite color"
When it comes to what is supported inside workflow, take a look at the built in help in workflow designer and search for "forms". On the page "Display Form Activity" we have listed all of the commonly used properties which can be accessed through runtime mods to help make things easier.
Cheers,
Kevin
0 -
Thanks Kevin, the SelectedValue is working.
To furthur expand on our requirement, is there any way we can presist the selected value from the combobox via a global variable to achieve the following:
- Open Search Workflow
- Select a value from combobox > Search > Workflow save selected value into a global variable
- Exit Workflow
- User do something...
- Open Search Worflow Again
- Workflow looks for the global variable, the set the default value in the combobox accordingly
From I've read in this forum, I think the answer is No, but I am asking again anyway, in case someone has manaaged to find a way.
0 -
If I was tasked to do this, I would build a custom module which contained a dictionary of objects. I'd then manipulate the dictionary through custom 'get and set' activity handlers which get called from workflow.
-Kevin
0 -
Jack,
I have always had better luck populating the listbox values with a derived list, using the Input Data param on the form. So, instead of putting the values in ComboBox1 > Data Items, build your own list, and feed it in that way. Your problem should get resolved.
Ryan
0 -
Thanks a lot Ryan. Have build my own dataitem variable fix the problem, which I hope it could be fixed in next release of GE.
regards,
Jack
0 -
Ryan,
what version of GE and SV you're using? I'm on GE3.15 and SV1.10. The workflow example you attached works all right in Workflow Designer simulator but when move to the server it fails to pick up the default value.
regards,
Jack
0 -
Jack,
We never upgraded from Essentials 3.14, SLV 1.9 because there is a bug in the latest and greatest > you cannot select an existing attribute in a ListBox (.SelectedValues) in RunTime on the form.
Ryan
0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
11 Kommentare