"Null" and "Read Only" fields are not displayed

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

ashah
Ebase User
Posts: 5
Joined: Thu Mar 17, 2022 1:39 pm

"Null" and "Read Only" fields are not displayed

#1

Postby ashah » Fri May 06, 2022 7:38 pm

how could I display an empty field control for the "Null" and "Read Only" fields?
0 x

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

Re: "Null" and "Read Only" fields are not displayed

#2

Postby Steve » Thu May 12, 2022 10:41 am

Hi,

An empty display only field control should show the field control with no value.. for example:

Code: Select all

//set null value
fields.myfield.value = null;
You should see the field with an empty value on the page.

Are you not seeing these on the page?

Kind regards

Steve
0 x

ashah
Ebase User
Posts: 5
Joined: Thu Mar 17, 2022 1:39 pm

Re: "Null" and "Read Only" fields are not displayed

#3

Postby ashah » Thu May 12, 2022 3:10 pm

Hi Steve,

When I have :

Code: Select all

fields.myfield.getFieldControl().setDisplayOnly(true);
fields.myfield.value = null;
It displays the control's label but not the control's editor.
Even If I assign the gray style class to that such as:

Code: Select all

fields.myfield.getFieldControl().setEditorClass('form-control readonly')
Still, it does not show the control editor to me.

Thanks,
Anousheh
0 x

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

Re: "Null" and "Read Only" fields are not displayed

#4

Postby Jon » Fri May 13, 2022 2:14 pm

If you've set the field to display only, you won't be able to edit it i.e. enter a value. Comment this line out and it should be editable.
0 x

ashah
Ebase User
Posts: 5
Joined: Thu Mar 17, 2022 1:39 pm

Re: "Null" and "Read Only" fields are not displayed

#5

Postby ashah » Mon May 16, 2022 12:38 pm

Actually, I need it to be displayed only. Although I cannot edit it, I would like it to show me the Control Editor appearance.
In case the field value is null, and the control is displayed only, the Control Editor disappears.
0 x

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

Re: "Null" and "Read Only" fields are not displayed

#6

Postby Jon » Tue May 17, 2022 9:07 am

If you want to display the field editor but disable it, you need to add the disabled attribute to the HTML input tag. To do this permanently, click on the field as it appears on the page, then in the Properties View select Html Element Properties, click the Editor Input tag and enter disabled in Custom Attributes.

To do this dynamically, you can add this as a Before Page event or any other event that runs before the page is displayed.

Code: Select all

var myField = fields.xxxxxx;         // Put your field name here

if (myField.value)
{
	myField.fieldControl.displayOnly = false;
	myField.fieldControl.editorHtmlElementProperties.setCustomAttributes("disabled");
}
else
{
	myField.fieldControl.displayOnly = true;
	myField.fieldControl.editorHtmlElementProperties.removeCustomAttribute("disabled");
}
0 x

ashah
Ebase User
Posts: 5
Joined: Thu Mar 17, 2022 1:39 pm

Re: "Null" and "Read Only" fields are not displayed

#7

Postby ashah » Fri May 20, 2022 2:36 pm

Hi Jon,

Thank you very much.

I actually need to be able to change the field value while it is read_only, and not just make the control disabled :(

I appreciate your help and support.
Anousheh
0 x

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

Re: "Null" and "Read Only" fields are not displayed

#8

Postby Jon » Sat May 21, 2022 10:12 am

Read only and editable are direct opposites and you can't have both at the same time - at any given time a Field Control (this is the control used to display a field on a page) is either read only or editable.

But you can change this dynamically in a number of ways - it depends on the UI you want. For example you could display a field initially as read only and then place an Edit hyperlink or an icon next to it to allow the user to edit the field. When clicked, this hyperlink/icon would then run a server side event to change the read only/editable state e.g.

myField.fieldControl.displayOnly = false;

You could also toggle the readonly/state if you wanted to e.g.

myField.fieldControl.displayOnly = !myField.fieldControl.displayOnly;

Similarly your starting point could be that the field control state is editable but you have added the disabled attribute (as we discussed earler). You could also toggle this in the same way as for display only - to allow the user to edit the field.

But I think the key to this is deciding up front exactly what UI you want. Then you can set about implementing it.
0 x


Who is online

Users browsing this forum: No registered users and 55 guests