Dropdown is hidden when making it display only

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Dropdown is hidden when making it display only

#1

Postby Segi » Tue Oct 23, 2018 11:51 pm

I have a form with a repeater

The repeater is structured in this way:

Parent repeater
Category 1 (parent repeater row)
(Child repeater row)
Option 1
Option 2
etc...
Category 2 (parent repeater row)
(Child repeater row)
Option 1
Option 2
etc...

When loading the form, I call this function:

Code: Select all

// Make the PCS editable or readonly. Header and body can be made editable independently
function PCSEditable(headerEnabled,bodyEnabled) {	   
	   // toggle enabled because the call to setDisplayOnly expects true to make it read only or false to make it editable
	   headerEnabled=!headerEnabled;
     bodyEnabled=!bodyEnabled;
     
	   // Header
	   for each (var ctrl in pages.Page_1.getControlsByModifier("PCSHEADER")){
	        ctrl.setDisplayOnly(headerEnabled);	
	   }

     var allSegments=tables.PCS_Template_Segments;

     // Loop through all option groups
     var allRows=tables.PCS_Template_OptionGroups;
     var rows=allRows.getRows();

     allSegmentRows=allSegments.getRows();

     while (rows.next()) {
          // Only process option groups for the current PCS Template ID
     	    if (allRows.PCS_TemplateID.value != fields.PCSTEMPLATEID.value) {
     	         continue;	
     	    }

     	    // Jump to category that relates to the current category
          parentRow=allSegments.findRow(allSegments.Segment_CategoryID,allRows.Segment_CategoryID.value);

          if (parentRow != -1) {
               allSegments.setCurrentRow(parentRow);
       
                // This is the problematic line
               allRows.OptionValues.fieldControl.setDisplayOnly(true);
          }
     }

     fields.CUSTOMERINSTRUCTIONS.fieldControl.setDisplayOnly(bodyEnabled);
     fields.GMSOFFICIALUSEONLY.fieldControl.setDisplayOnly(bodyEnabled);

     	// If body is editable, the save button needs to be visible
       controls.SAVEBUTTON.setHidden(bodyEnabled);
       controls.SAVEBUTTON_2.setHidden(bodyEnabled);
}
The line with the comment This is the problematic line is where the problem is happening. I am setting this field to display only but it gets hidden.

This field is set as a dropdown tied to a dynamic list set to to be built on each display and has a mapped field which is mapped to a column in a table resource.

If I comment out the problematic line the dropdown is visible and is selectable. There is no other code that affects the controls on the form.

I need help understanding why setting a control to display only hides it instead of making it read only.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Dropdown is hidden when making it display only

#2

Postby Jon » Wed Oct 24, 2018 9:30 am

I'm guessing that by hidden you mean that nothing is shown in the column. Are you sure that this field has a value and the value appears in the list?

This is what is expected to happen and it varies depending on whether the setDisplayOnly() is issued when the table is empty or not:

Table empty: sets display only as a default attribute value for all rows - when the table is subsequently loaded all rows should be display only. The field value should be shown so long as it appears in the list.

Table loaded: sets display only for the current row of the table - will be the first row if you've used fetchTable(). All other rows should be editable.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Dropdown is hidden when making it display only

#3

Postby Segi » Wed Oct 24, 2018 3:23 pm

Jon,

All of the dropdowns have a list of values that you can choose from and have a default selected value. When I call setDisplayOnly(true) on the dropdown in a repeater by doing allRows.OptionValues.fieldControl.setDisplayOnly(true); the result is the same as if I had called setHidden(). The dropdown is not visible at all and the selected value is hidden. I.E. Its just not there

The dropdown is bound to a column in the repeater that contains an ID number. This id # is used to build the dynamic list.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

Re: Dropdown is hidden when making it display only

#4

Postby Jon » Wed Oct 24, 2018 3:49 pm

Sorry I hadn't managed to scroll down that far. I'm not sure that "allRows.OptionValues.fieldControl" will return the right object as you loop through the table's rows. Could you try invoking setDisplayOnly() directly on the control e.g. controls.Fldxxxxxx.setDisplayOnly().
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Dropdown is hidden when making it display only

#5

Postby Segi » Wed Oct 24, 2018 5:04 pm

Jon,

That has the exact same effect

Segi
0 x

Steve
Moderator
Moderator
Posts: 414
Joined: Fri Sep 07, 2007 3:44 pm
Location: Sandy, UK
Contact:

Re: Dropdown is hidden when making it display only

#6

Postby Steve » Thu Oct 25, 2018 10:15 am

Hi Segi,

Could you download my test form here

Press the Hide me button. You can see in the script, that it is very simple script that loops through and sets the field control as display only.

I cannot see a problem. I am using Verj 5.4.0, but I do not think this has changed. You can import into any version from 5.0+.

Could it be that there is no value in the dropdown and it looks as though the field is hidden, but it's not?

Kind regards

Steve
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Re: Dropdown is hidden when making it display only

#7

Postby Segi » Mon Oct 29, 2018 9:00 pm

I have figured out what was causing the issue and fixed it thanks
0 x


Who is online

Users browsing this forum: No registered users and 12 guests