spDatePicker ReadOnly

B Praveen Rao
Tera Contributor

Hi,

I am trying to build a custom widget where I am trying to use the sp-date-picker for datetime fields.

I have a requirement to make those fields read only and editable based on a "Edit" button.

When I try using direct scope element it's working fine 

<sp-date-picker ng-if="field.type == \'date\'" field="field" ng-model="c[field.name]" sn-disabled="fieldReadOnly" ></sp-date-picker>'

When I try to use directive under the ng-repeat and passing the dynamic 'c' object it's not working (either a boolean or function)

<sp-date-picker ng-if="field.type == \'date\'" field="field" ng-model="c[field.name]" sn-disabled="c[field.readOnlyName]" ></sp-date-picker>'

OR

<sp-date-picker ng-if="field.type == \'date\'" field="field" ng-model="c[field.name]" sn-disabled="field.isReadOnly()" ></sp-date-picker>'

Thanks in advance.

2 REPLIES 2

Aniket Sawant2
Giga Guru

Hi,

You can set attribute 

sn-disabled="true"

true/false based on condition in edit button.

 

or take value of field.isReadOnly() in data object and pass it to html and check it is true or not 

 

please mark helpful /correct based on impact

Regards,

Aniket S

Hi,

I already tried using field.isReadOnly() but it's not working.

If it works for you, please share the code.

 

Thanks