Reset value in a reference group with a segmented control

Say you have a reference group control, and it's content is made up of a segmented control. The users are requesting that you reset the entire value if you go to any of the control's inner controls and delete the value in it.
To do this you would simply parse the segmented control's controls, override their modified method and set the reference group bounded column's value to 0. The code to do this would be:

a) in the form's Run method:

public void run()
    Object                      formControlObject;
    FormControl                 formControl;
    FormStringControl           formStringControl;
    FormReferenceGroupControl   referenceGroupControl;
    int                         i;


    referenceGroupControl =, salestable_DeliveryPostalAddress));

    for (i = 1; i <= referenceGroupControl.controlCount(); i++)
        formControl = referenceGroupControl.controlNum(i);
        formStringControl = formControl as FormStringControl;

        if (formStringControl != null)
            formStringControl.registerOverrideMethod(methodStr(FormStringControl, modified), identifierStr(resetReferenceGroupModified), element);

b) the override method: 

public boolean resetReferenceGroupModified(FormStringControl _control)
    if (_control.text() == '')
        salestable.DeliveryPostalAddress = 0;

    return true;

The salesTable datasource used here as well as the field are just to give you an example, so do replace them according to your needs. Also you can notice that I am only handling in this example the case when all the replacement controls are string edit; so, do implement for date, int, numeric, etc when required - observe the cast I'm doing from FormControl to FormStringControl; you can also do a more generic cast, to Object and this way your will handle all the possible cases; but then you will have to rewrite a little bit the signature of the used method.

No comments:

Post a Comment