How to Set Input Widget Read Only Attribute Dynamically?

Hi,

How I can set readonly attribute on an input widget dynamically? 

For example if a User open detail screen that is not made by him / createdby <> getuserid(), I want the input widget set to read only, the user won't be able to edit it but still able to scroll down the text area.

But if the createdby = getuserid(), then the input widget readonly attribute will be set to false.

Kevin Wie wrote:

Hi,

How I can set readonly attribute on an input widget dynamically? 

For example if a User open detail screen that is not made by him / createdby <> getuserid(), I want the input widget set to read only, the user won't be able to edit it but still able to scroll down the text area.

But if the createdby = getuserid(), then the input widget readonly attribute will be set to false.

Hi Kevin,

Can you please elaborate more...What exact you want as output


Amreen Shaikh wrote:

Kevin Wie wrote:

Hi,

How I can set readonly attribute on an input widget dynamically? 

For example if a User open detail screen that is not made by him / createdby <> getuserid(), I want the input widget set to read only, the user won't be able to edit it but still able to scroll down the text area.

But if the createdby = getuserid(), then the input widget readonly attribute will be set to false.

Hi Kevin,

Can you please elaborate more...What exact you want as output


Hi Amreen,

I want to set Input widget extended properties "readonly" dynamically based on the user logged in


Kevin Wie wrote:

Amreen Shaikh wrote:

Kevin Wie wrote:

Hi,

How I can set readonly attribute on an input widget dynamically? 

For example if a User open detail screen that is not made by him / createdby <> getuserid(), I want the input widget set to read only, the user won't be able to edit it but still able to scroll down the text area.

But if the createdby = getuserid(), then the input widget readonly attribute will be set to false.

Hi Kevin,

Can you please elaborate more...What exact you want as output


Hi Amreen,

I want to set Input widget extended properties "readonly" dynamically based on the user logged in




Apply your condition on enable property


hope this will help you

regards,

Amreen

Amreen Shaikh wrote:



Apply your condition on enable property


hope this will help you

regards,

Amreen

Hi Amreen,

I don't want the Input widget to be disabled. I want it stay enabled but "Read Only", means if the text is very long inside 2 Text Lines Input widget the user still can scroll the Input Widget to see the rest of the text but won't be able to edit it.


Solution

So in  that case you can use expression to view it.

Solution

Amreen Shaikh wrote:

So in  that case you can use expression to view it.

Not exactly what I'm looking for but it give me an idea of another workaround.

THanks Amreen :)


Hi Kevin,

You can use the Extended Properties section to add additional attributes to your HTML elements. If you define a Property set to readonly your browser will render your Input as read-only. Do note that your end-users can easily change this by using the browser developer tools, so do not use it for security purposes. Also important is that, as mentioned here, a read-only input is still going to be submitted to the server (and a disabled one won't).

A second alternative would be to use an Expression, like Amreen suggested above, and if you really want to make it look like an input, just give it the input Style Class, and also a line-height style that matches the height of your inputs.

Jorge Martins wrote:

Hi Kevin,

You can use the Extended Properties section to add additional attributes to your HTML elements. If you define a Property set to readonly your browser will render your Input as read-only. Do note that your end-users can easily change this by using the browser developer tools, so do not use it for security purposes. Also important is that, as mentioned here, a read-only input is still going to be submitted to the server (and a disabled one won't).

Hi Jorge,

I know how to define the property set to readonly, but I don't know how to make it dynamically, like removing the property on certain condition.

A second alternative would be to use an Expression, like Amreen suggested above, and if you really want to make it look like an input, just give it the input Style Class, and also a line-height style that matches the height of your inputs.

And yes, this is the workaround I did.