Display blank record as default in drop-down in MVC

This forum allows users to post and respond to "How Do I Do ....." questions. The information contained in this forum has not been validated by K-Rise Systems and, as such, K-Rise Systems cannot guarantee the accuracy of the information.
Post Reply
kathy.pride
Posts: 47
Joined: September 7th, 2021, 1:04 pm
Contact:

Display blank record as default in drop-down in MVC

Unread post by kathy.pride »

I have a drop-down field which gets its values from a SQL table. How do I set it to default to a blank value vs. the first value in the list? In previous version in Appearance section, there was an option for "Default Text" which I set to blank and then "Show Default" which I set to Yes.
word count: 59

Tags:
JustinVanRegenmorter
Posts: 536
Joined: August 26th, 2021, 9:56 am
Contact:

Re: Display blank record as default in drop-down in MVC

Unread post by JustinVanRegenmorter »

Hello Kathy,

Here are two examples to achieve the blank record as the first value in a DropDown control in MVC.

The first example uses a CreateServiceNode service and an Inquire service with the same name.
Example1_Services.PNG
Example1_Services.PNG (6.52 KiB) Viewed 4683 times
Example1_Services.PNG
Example1_Services.PNG (6.52 KiB) Viewed 4683 times
The CreateServiceNode service creates the blank record by setting the name node to the result from the inquire that will be displayed in the Dropdown and nothing in the result node.
Example1_CreateServiceNode.PNG
Example1_CreateServiceNode.PNG (27.3 KiB) Viewed 4683 times
Example1_CreateServiceNode.PNG
Example1_CreateServiceNode.PNG (27.3 KiB) Viewed 4683 times
Then the Inquire service will be setup with the "Append Service Output" property set to true to add the Inquire's results onto the CreateServiceNode results. This property is indicated by a purple dot in the top left corner of the service. The "Expose Service Output" property should also be set to true and is indicated by a green dot in the top left corner of the service. This property allows the controls to see that services output.
Example1_Inquire.PNG
Example1_Inquire.PNG (78.57 KiB) Viewed 4683 times
Example1_Inquire.PNG
Example1_Inquire.PNG (78.57 KiB) Viewed 4683 times
Then in the Dropdown control set the Loop property to the "Result" node of the inquire service and the Text and Value properties to the column name from the inquire service.
Example1_ControlProperties.PNG
Example1_ControlProperties.PNG (37.92 KiB) Viewed 4683 times
Example1_ControlProperties.PNG
Example1_ControlProperties.PNG (37.92 KiB) Viewed 4683 times


The second example uses a CreateServiceNodeFromXml service and an Inquire service where the names don't have to be the same.
Example2_Services.PNG
Example2_Services.PNG (6.54 KiB) Viewed 4683 times
Example2_Services.PNG
Example2_Services.PNG (6.54 KiB) Viewed 4683 times
The Inquire service is first in this example and is setup with only the "Expose Service Output" property set to true.
Example2_Inquire.PNG
Example2_Inquire.PNG (79.81 KiB) Viewed 4683 times
Example2_Inquire.PNG
Example2_Inquire.PNG (79.81 KiB) Viewed 4683 times
Then the CreateServiceNodeFromXml service will contain a blank xml node with the column name. After the blank node add a XSLT for-each loop on the "Result" node of the inquire using the XSLT selector popup menu by clicking on the "Result" node from the Assistant tab. Inside the for-each loop add the same column name in xml and then add an XSLT value-of select on just the column name from the inquire service.
Example2_XSLTSelector.PNG
Example2_XSLTSelector.PNG (45.53 KiB) Viewed 4683 times
Example2_XSLTSelector.PNG
Example2_XSLTSelector.PNG (45.53 KiB) Viewed 4683 times
Example2_CreateServiceNodeFromXml.PNG
Example2_CreateServiceNodeFromXml.PNG (26.75 KiB) Viewed 4683 times
Example2_CreateServiceNodeFromXml.PNG
Example2_CreateServiceNodeFromXml.PNG (26.75 KiB) Viewed 4683 times
Then in the Dropdown control set the Loop property to the Column Name node of the CreateServiceNodeFromXml service and the Text and Value properties to the same node.
Example2_ControlProperties.PNG
Example2_ControlProperties.PNG (41.07 KiB) Viewed 4683 times
Example2_ControlProperties.PNG
Example2_ControlProperties.PNG (41.07 KiB) Viewed 4683 times
word count: 484
Post Reply