PDA

View Full Version : User Defined Smart Fields and Browses


ABC123

Tbaker
03-16-2008, 01:03 PM
I am try to test the User Defined Smart Field in browses

The what's new in V9 describes how to set the udsm as follows


To define a smart-field, right click on the column and select Properties. On the 'Setup' tab, check the 'User Defined Smart Field' checkbox.



In testing I tried to do this. For the form (see first thumbnail) when you click on the set up tab of properties at the bottom of the genie is the checkbox for the user defined smart field.

For a browse (both named and embedded) when you click on a column and then right click properties then set up tab - there is no check box for user defined smart fields.

Am I missing something?

Tom Baker

MoGrace
07-17-2017, 04:18 PM
I cannot find a link to What's new in Version 9 anymore where this feature is explained. However it still exists in the legacy documentation - but of course without pictures.

I wanted to add the short time picker to a column in an embedded browse for a character field, and that field type option was not available - even though the time() function returns a character value. There is a focus_button property for each of the columns but it is not exposed in the properties editor. So this is how to do it:

In the OnInit event for the form set the icon for the button using this format browse_name:column_name.focus_button = "image_name"

Ex: browse1:SIGN_IN.focus_button = "$$control.clock"

Right click on the embedded browse and create a function in the Browse/Events (if you have other events already defined then the selection will be Browse/Events/Events)

use your own column name instead of SIGN_IN - and substituting ' this.value ' for sign_in.value ought to work as well and make it more generic since you are in the active field.

FUNCTION SIGN_IN_FocusButtonClick AS V ( )
if sign_in.value = "" then
sign_in.value = time("0h:0m AM",now())
else
dim vtime as Y
vtime = ctot(ui_get_short_time("Sign In Time",time("0h:0m AM",now() )))
sign_in.value = time("0h:0m AM",vtime)
end if

topparent.commit()
sign_in.refresh()
END FUNCTION

When the field is active the clock appears and if the field is blank, the first click inserts the current time (quick method); then a 2nd click on the button will popup the short time picker for editing.

The nice part of using a smart field here instead of adding an unbound browse button, is that it only appears if the field is active instead of showing all the time.

Hope somebody else finds this useful because the option ought to be in the v12 desktop!

Stan Mathews
07-17-2017, 04:38 PM
www.alphasoftware.com/documentation/pages/Index/Alpha Five V9.xml

but no pictures. Supposed to link to a video.

MoGrace
07-18-2017, 11:44 AM
I got the 404 page for that link

Stan Mathews
07-18-2017, 12:20 PM
https://www.alphasoftware.com/documentation/pages/Index/Alpha%20Five%20V9.xml

Trying again, link looks different this time.

4373243733

MoGrace
07-19-2017, 02:20 AM
Well, I did send in a complaint that this info was not there earlier :grin:

MoGrace
09-11-2017, 07:09 PM
Having watched both videos, neither of those methods Selwyn used will blank the value if the user selects the cancel button. IOW there is no way to trap the result and thus the field will always get updated. Too bad, I guess I can use another button to clear the field...

MoGrace
11-09-2017, 04:32 PM
A rather crucial error above kept this from working :rolleyes:

FUNCTION SIGN_IN_FocusButtonClick AS V ( )
if browse1:sign_in.value = "" then
browse1:sign_in.value = time("0h:0m AM",now())
else
dim vtime as Y
vtime = ctot(ui_get_short_time("Sign In Time",time("0h:0m AM",now() )))
browse1:sign_in.value = time("0h:0m AM",vtime)
end if

topparent.commit()
browse1:sign_in.refresh()
END FUNCTION

Since this subject has little info available and the other posts have no links anymore, thought I should update this. Also 'this.value' will not work, since this is not the same type of event that a _buttonclick or _titleclick event would require. You do not include 'this.Set_Viewport_row(row)' or use the same parameters in this function, and instead address the column field as above.

MoGrace
08-17-2018, 05:34 PM
Now I am trying to figure out how to verify that the user picked a valid time since they could easily miss the need to change AM to PM or vice versa.

Ira mentions HERE (https://www.alphasoftware.com/alphaforum/showthread.php?107394-The-UI_Get_Short_Time()-Function&p=653716&viewfull=1#post653716) that he has replacements for the time and calendar functions - perhaps he will share...