Adding custom pick-lists to dialogs

Top  Previous  Next

DISCLAIMER: This article involves Advanced Customizations, which can be technically challenging to get working and is not part of standard support.  This is programming and must be done precisely or the results can be unpredictable.  This information is provided as a service for those who have the technical skills to work through it -- we cannot help you solve any issues with getting it working.  For more information about Advanced Customizations, see the full documentation:

https://campgroundmaster.com/help/overview32.html

 

 

When adding custom data fields, you may want to add a data field and dialog selection list that only has certain choices that the operator can choose from, the way Campground Master uses Pick Lists.

 

While it isn't possible to define a new Pick List, it is possible to use the "Drop-down list box" control type to limit the choices just like a pick list.  

 

First of all, when adding the data field, be sure to make it a "Text : General" field type.

 

When creating the Dialog definition you can use Quick Add Fields to add the new field to a dialog, which will add the input control as an "Edit text" control.  Next you'll need to modify the control type to "Drop-down list box", and change the expressions appropriately.

 

The examples below show how the Initialize and OK/Save expressions should look -- of course you need to change "My List Input" to the proper control name, and use your real data field name in place of "<field name>".

 

The Initialize expression should look like:

 

Eval(DlgClearUserDropList("My List Input"), DlgAddUserDropListText("My List Input","Item 1"), DlgAddUserDropListText("My List Input","Item 2"), DlgSetUserDropListSelectedText("My List Input", FieldText(This(),"<field name>")))

 

Of course you should replace "Item 1", etc. with the text you want to show, and you can add as many "Items" as you need by inserting more DlgAddUserDropListText functions (make sure DlgSetUserDropListSelectedText is still the last function, though).

 

The OK/Save expression should look like:

 

SetFieldText(This(),"<field name>", DlgGetUserDropListSelectedText("My List Input"))

 

Now the field will behave just like other pick-list based fields.  The main difference is that changing the selections in the list by altering the expression above won't affect any previously entered data -- the old text will remain in the previous fields (resulting in the field appearing blank when viewed in the dialog again) -- so make sure the text selections are what you will always want to use, and avoid changing selections previously used (but they can be rearranged or added to later if needed).

 

Note: You'll need version 4.1 or later for the DlgClearUserDropList function -- without this, the list can keep duplicating itself if using Next/Prev buttons in dialogs like Customer Details or Site Details.

 

 


Page URL https://CampgroundMaster.com/help/addedcustompick-liststodia.html

Campground Master Home