How to set default item for ComboBox on Form activity?
Hi all,
Does anyone know to set the default value for a ComboBox on a Form with Workflow Designer?
For example, I've got a list of items for a ComboBox, say "Orange", "Apple" and "Pear"; I want the ComboBox shows "Apple" as default when the form is displayed.
The Geocortex WorkFlow help for 3.9 only gives the following attributes of a ComboBox that can be configured by the new "RuntimeModifications" activity:
ComboBoxFormIteml
- form.Find(Of ComboBoxFormItem)("<FormItemID>").Label.Textl
- form.Find(Of ComboBoxFormItem)("<FormItemID>").QueryServiceUrll
- form.Find(Of ComboBoxFormItem)("<FormItemID>").QueryWhereClausel
- form.Find(Of ComboBoxFormItem)("<FormItemID>").Token
None of them deals with default value for the combobox.
Additionally, Workflow Designer complained "ComboBoxFormItem not defined" when I add one of the lines above to To of an Assign activity following the User Manual. Any idea?
Thanks for your help.
Cheers,
Alex
-
Hi Alex
to get it to stop complaining you need to import, using third tab at the bottom of the designer labelled Imports, Geocortex.Forms.Client.Items
In regards to the default item could you just set the items so that your default item is the first in the list rather than in the middle of the list of items.?
Having the option to use:
- form.Find(Of ComboBoxFormItem)("<FormItemID>").SelectedIndex or
- form.Find(Of ComboBoxFormItem)("<FormItemID>").SelectedItem
would be helpful but does not appear to be currently available.
Thanks
Ralph Price
0 -
Hi Ralph,
I totally agree that having an option like
- form.Find(Of ComboBoxFormItem)("<FormItemID>").SelectedIndex or
- form.Find(Of ComboBoxFormItem)("<FormItemID>").SelectedItem
would be really helpful.
I followed your instruction and managed to import the required library and it worked.
I tried to make the default value as the first item of the list, however, the combobox still had no default value as no selected item populated, so I still need to manually select the first item as the desired value.
Any further idea?
Thanks
Cheers,
Alex
0 -
Hi Alex
that seems a little odd as it seems to work here (3.9/1.5 combination).
Try this workflow:
<Activity mc:Ignorable="sap" x:Class="{x:Null}" sap:VirtualizedContainerService.HintSize="343,583" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:eac="clr-namespace:ESRI.ArcGIS.Client;assembly=ESRI.ArcGIS.Client" xmlns:eacg="clr-namespace:ESRI.ArcGIS.Client.Geometry;assembly=ESRI.ArcGIS.Client" xmlns:eact="clr-namespace:ESRI.ArcGIS.Client.Tasks;assembly=ESRI.ArcGIS.Client" xmlns:gcx="http://apis.geocortex.com/2009" xmlns:gfc="clr-namespace:Geocortex.Forms.Client;assembly=Geocortex.EssentialsWpfApi" xmlns:gr="clr-namespace:Geocortex.Reporting;assembly=Geocortex.Reporting" xmlns:gwa="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow" xmlns:gwa1="clr-namespace:Geocortex.Workflow.Activities;assembly=Geocortex.Workflow.Activities" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=System.Core" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=mscorlib" xmlns:sa="clr-namespace:System.Activities;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Sequence sap:VirtualizedContainerService.HintSize="303,543" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
<gwa1:DisplayForm FormDefinition="<FormDefinition xmlns="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><ContainerFormItem xmlns:a="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items"><a:ArgumentName/><a:ItemID>Group1</a:ItemID><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:Description/><a:FormItems><a:FormItem i:type="a:ComboBoxFormItem"><a:ArgumentName/><a:ItemID>ComboBox1</a:ItemID><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:DataItems><DataItem><Display>apple</Display><TypeName>System.String</TypeName><Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">apple</Value></DataItem><DataItem><Display>rhubarb</Display><TypeName>System.String</TypeName><Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">rhubarb</Value></DataItem><DataItem><Display>banana</Display><TypeName>System.String</TypeName><Value i:type="b:string" xmlns:b="http://www.w3.org/2001/XMLSchema">banana</Value></DataItem></a:DataItems><a:FilterByInputGeometry>false</a:FilterByInputGeometry><a:Label><a:ArgumentName/><a:ItemID/><a:ToolTip/><a:ValidationItems xmlns:b="http://schemas.datacontract.org/2004/07/Geocortex.Forms.Client.Items.Validation"/><a:LabelForItemID>ComboBox1</a:LabelForItemID><a:Text>Fruit</a:Text></a:Label><a:ProxyUrl/><a:QueryCascadingID/><a:QueryDisplayOutputField/><a:QueryServiceUrl/><a:QueryValueOutputField/><a:QueryWhereClause/><a:SelectText/><a:Token/></a:FormItem></a:FormItems><a:MaxWidth>INF</a:MaxWidth><a:Orientation>Vertical</a:Orientation></ContainerFormItem><KnownTypes xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><a:string>Geocortex.Forms.Client.Items.ContainerFormItem</a:string><a:string>Geocortex.Forms.Client.Items.ComboBoxFormItem</a:string></KnownTypes><MaxHeight>800</MaxHeight><MaxWidth>1000</MaxWidth><Title>Form Title</Title><Version>1.1</Version></FormDefinition>" sap:VirtualizedContainerService.HintSize="281,419">
<gwa1:DisplayForm.Body>
<ActivityAction x:TypeArguments="gcx:FormDefinition">
<ActivityAction.Argument>
<DelegateInArgument x:TypeArguments="gcx:FormDefinition" Name="form" />
</ActivityAction.Argument>
<Sequence DisplayName="RuntimeModifications" sap:VirtualizedContainerService.HintSize="200,49">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</Sequence>
</ActivityAction>
</gwa1:DisplayForm.Body>
<gwa1:DisplayForm.FormInArguments>
<gwa:ArgumentWrapper x:TypeArguments="InArgument(scg:IEnumerable(gcx:DataItem))" IsRequired="False" Name="ComboBox1">
<gwa:ArgumentWrapper.Argument>
<InArgument x:TypeArguments="scg:IEnumerable(gcx:DataItem)" />
</gwa:ArgumentWrapper.Argument>
</gwa:ArgumentWrapper>
</gwa1:DisplayForm.FormInArguments>
</gwa1:DisplayForm>
</Sequence>
</Activity>Basically just displays a form but the dropdown list aka combobox does have Apple selected when run.
Thanks
Ralph
0 -
Hi Ralph,
Thanks for the code sample!
Yes, it worked on my side as well.
However, when the list of values comes from a query task for the ComboBox or a converted DataItems as input list rather than manually added, it doesn't automatically populates the first item of the list as default (selected) but an empty space.
Could it be a bug or something to improve in future?
Regards,
Alex
0 -
Hi Alex,
There is no way to set the default selected item in ComboBox/Listbox. This is a feature on our list and should be available sometime in the future.
Cheers,
Christian.
0 -
Hi Alex,
Are there any updates on this.
Thanks.
Vipul0 -
Hi Vipul,
If you're asking about the availability of the feature Christian mentions above, the ability to programmatically set a default selected value for a combo box or list box was added to the Silverlight API in Geocortex Viewer for Silverlight 1.9 and to the JavaScript API in Geocortex Viewer for HTML5 2.4.1.0 -
Hi Jordan,
I have a ComboBoxFormItem that I am creating in the RuntimeModifications sequence of a Form, but I cannot later set the SelectedValue.
The ComboBoxFormItem in question is populated via QueryCascadingID once a value in the above ComboBoxFormItem is selected, but is initialised by AddRangeToCollection<DataItem> on the DataItems property prior to that value changing. The ComboBoxFormItem assignment is below for more context:new ComboBoxFormItem() With { .Label=New LabelFormItem With { .Text="Type" }, .ArgumentName="ASSET_TYPE_ID", .QueryServiceUrl=AssetClassTypeLayerUrl, .QueryWhereClause="ASSET_CLASS_ID={1:AssetClassIdComboBox}", .QueryValueOutputField="ASSET_TYPE_ID", .QueryDisplayOutputField="ASSET_TYPE", .QueryCascadingID=classComboBox.ItemID, .SelectText=" " }GeoCortex Essentials/Workflow Designer 4.6.2 and HTML 5 Viewer 2.7.1 are the versions I am running, is it possible that SelectedValue / SelectedItem cannot be set in RuntimeModifications for some reason specific to this use case?
Brad0 -
Hi Brad,
I am able to set a SelectedValue for a ComboBoxFormItem that is created in RuntimeModifications and populated by QueryCascadingID from another ComboBoxFormItem. I'm a bit confused about what is being set with DataItems, and how and where this is occurs in your workflow. Could you post some clarification for this part or maybe a sample workflow?
Thanks!
Amanda0
Please sign in to leave a comment.
Comments
9 comments