cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How can I change "ReadOnly" attribute of Textbox widget dynamically?

SOLVED
shasegawa
Newbie

How can I change "ReadOnly" attribute of Textbox widget dynamically?

When I use built-in textbox widget, how can I change "ReadOnly" attribute of the textbox widget depends on login user? For example, only users belongs to Administrator group can change value of text box and generic user only can see the value.

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: How can I change "ReadOnly" attribute of Textbox widget dynamically?

Hi Yamini, I don't think that this was what he was asking for.

Hi Satoshi, unfortunately ReadOnly property on TextBox Widget isn't bindable, then you can't set ReadOnly/Not ReadOnly on runtime.

What I would do it's add two widgets the same place, one TextBox and a ValueDisplay, and show/hide them ( visibility property it's bindable ) depending on the current user permissions.

Of course, you have to build a custom service which tells you if the user has ReadOnly or Read/Write access to the given property. This can be done checking the Group's ownership of the user, or as pointed out by Yamini, setting according permissions to the property and checking on this custom service which kind of access has the user on the given property.

To check current user's groups:

var userGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();

To check user's permissions to a given property:

var hasReadPermission = me.CheckPermission({ name: "propertyName", type: "PropertyRead" });

var hasWritePermission = me.CheckPermission({ name: "propertyName", type: "PropertyWrite" });

View solution in original post

3 REPLIES 3

Re: How can I change "ReadOnly" attribute of Textbox widget dynamically?

Hi Satoshi, Click on your desired Thingtemplate or thing and select Run Time link in the explorer. Now in (All Properties, Events, and services )-->type the group or user you want to set the permissions.  Select the green dot to allow and red dot to deny.  You can also set permissions to individual properties in (property,Service or Event Overrides). Let me know if this doesn't solve your problem .

Re: How can I change "ReadOnly" attribute of Textbox widget dynamically?

Hi Yamini, I don't think that this was what he was asking for.

Hi Satoshi, unfortunately ReadOnly property on TextBox Widget isn't bindable, then you can't set ReadOnly/Not ReadOnly on runtime.

What I would do it's add two widgets the same place, one TextBox and a ValueDisplay, and show/hide them ( visibility property it's bindable ) depending on the current user permissions.

Of course, you have to build a custom service which tells you if the user has ReadOnly or Read/Write access to the given property. This can be done checking the Group's ownership of the user, or as pointed out by Yamini, setting according permissions to the property and checking on this custom service which kind of access has the user on the given property.

To check current user's groups:

var userGroups = Resources["CurrentSessionInfo"].GetCurrentUserGroups();

To check user's permissions to a given property:

var hasReadPermission = me.CheckPermission({ name: "propertyName", type: "PropertyRead" });

var hasWritePermission = me.CheckPermission({ name: "propertyName", type: "PropertyWrite" });

View solution in original post

Re: How can I change "ReadOnly" attribute of Textbox widget dynamically?

Hi Carlos,

Thank you for your support. Perhaps, I can realize what I wanted to do in the way you suggested.

Thank you very much.

Announcements

Check out the upcoming Expert Session: Understanding ThingWorx Navigate Licensing in Community "Customer Events" section.