Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show and hide form element using Angular2 DevExtreme

I'm trying to show and hide a form field using Angular's *ngIf but, when I do, the entire form doesn't render no matter the value I give the *ngIf and no errors are thrown. Clearly the *ngIf isn't the way to go. Is there a more DevExtreme way to do this? I see there is a visible in the documentation but I don't just want to hide it.

HTML

<dx-form id="companyDetailsForm" [(formData)]="company" [showColonAfterLabel]="false">
  <dxi-item dataField="Name">
    <dxi-validation-rule type="required" message="Name is required"></dxi-validation-rule>
  </dxi-item>
  <dxi-item *ngIf="hasParent" dataField="Parent" caption="Parent">
    <dxo-label text="Parent"></dxo-label>
  </dxi-item>
</dx-form>
like image 249
Aaron Salazar Avatar asked Dec 14 '25 15:12

Aaron Salazar


1 Answers

Use visible property instead, *ngIf does not work in the DX Form.

<dxi-item [visible]="hasParent"
like image 191
Václav Švára Avatar answered Dec 16 '25 15:12

Václav Švára



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!