Angular-QueryBuilder icon indicating copy to clipboard operation
Angular-QueryBuilder copied to clipboard

Changing entity doesn't refresh the dependent fields (custom controls)

Open lukaszsoleski opened this issue 6 years ago • 2 comments

Hello!

I followed the example of Angular Material and customized the component using the Telerik Kendo library. However, I encountered a problem related to entity mode. Changing entity does not refresh the dependent fields. I get the following error in the console:

error

After digging through the source code it looks like "changeEntity" function binded to onChange doesn't get all parameters: "index : number" and "data : RuleSet". I checked the example of Angular Material and the error also occurs there.

lukaszsoleski avatar Feb 02 '20 18:02 lukaszsoleski

If you don't use validation rules, you can remove the onChange and let the ngModel do the job :

<ng-container *queryEntity="let rule; let entities=entities;">
	<mat-form-field>
		<mat-select *ngIf="rule" [(ngModel)]="rule.entity">
			<mat-option *ngFor="let entity of entities" [value]="entity.value">
						{{entity.name}}
			</mat-option>
		</mat-select>
	</mat-form-field>
</ng-container>
<ng-container *queryField="let rule; let fields=fields;let getFields = getFields">
	<mat-form-field>
		<mat-select [(ngModel)]="rule.field">
			<mat-option *ngFor="let field of getFields(rule.entity)" [value]="field.value">
						  {{ field.name }}
			</mat-option>
		</mat-select>
	</mat-form-field>
</ng-container>

ACivilise avatar Apr 09 '20 11:04 ACivilise

If you don't use validation rules, you can remove the onChange and let the ngModel do the job :

<ng-container *queryEntity="let rule; let entities=entities;">
	<mat-form-field>
		<mat-select *ngIf="rule" [(ngModel)]="rule.entity">
			<mat-option *ngFor="let entity of entities" [value]="entity.value">
						{{entity.name}}
			</mat-option>
		</mat-select>
	</mat-form-field>
</ng-container>
<ng-container *queryField="let rule; let fields=fields;let getFields = getFields">
	<mat-form-field>
		<mat-select [(ngModel)]="rule.field">
			<mat-option *ngFor="let field of getFields(rule.entity)" [value]="field.value">
						  {{ field.name }}
			</mat-option>
		</mat-select>
	</mat-form-field>
</ng-container>

Hi ACivilise, On removal of onChange it does not show error rules undefined but Changing entity does not refresh the dependent fields.

Rekhajikki avatar Jul 16 '20 12:07 Rekhajikki