"Null" and "Read Only" fields are not displayed
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 5
- Joined: Thu Mar 17, 2022 1:39 pm
"Null" and "Read Only" fields are not displayed
how could I display an empty field control for the "Null" and "Read Only" fields?
0 x
-
- Moderator
- Posts: 416
- Joined: Fri Sep 07, 2007 3:44 pm
- Location: Sandy, UK
- Contact:
Re: "Null" and "Read Only" fields are not displayed
Hi,
An empty display only field control should show the field control with no value.. for example:
You should see the field with an empty value on the page.
Are you not seeing these on the page?
Kind regards
Steve
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;
Are you not seeing these on the page?
Kind regards
Steve
0 x
-
- Ebase User
- Posts: 5
- Joined: Thu Mar 17, 2022 1:39 pm
Re: "Null" and "Read Only" fields are not displayed
Hi Steve,
When I have :
It displays the control's label but not the control's editor.
Even If I assign the gray style class to that such as:
Still, it does not show the control editor to me.
Thanks,
Anousheh
When I have :
Code: Select all
fields.myfield.getFieldControl().setDisplayOnly(true);
fields.myfield.value = null;
Even If I assign the gray style class to that such as:
Code: Select all
fields.myfield.getFieldControl().setEditorClass('form-control readonly')
Thanks,
Anousheh
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Re: "Null" and "Read Only" fields are not displayed
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
-
- Ebase User
- Posts: 5
- Joined: Thu Mar 17, 2022 1:39 pm
Re: "Null" and "Read Only" fields are not displayed
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.
In case the field value is null, and the control is displayed only, the Control Editor disappears.
0 x
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Re: "Null" and "Read Only" fields are not displayed
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.
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
-
- Ebase User
- Posts: 5
- Joined: Thu Mar 17, 2022 1:39 pm
Re: "Null" and "Read Only" fields are not displayed
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
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
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Re: "Null" and "Read Only" fields are not displayed
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.
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 6 guests