|
. . . . . . . . . .
export class AppComponent implements OnInit, AfterViewInit {
public data: Object[];
public initialPage: Object;
public orderForm: FormGroup;
public columns;
public newColumns;
public flag = true;
@ViewChild("grid") gridObj: GridComponent;
@ViewChild("childTemplate", { static: true })
public template: TemplateRef<{}>;
public childGrid: any;
constructor(
@Inject(ViewContainerRef) private viewContainerRef?: ViewContainerRef
) {}
ngAfterViewInit() {
this.template.elementRef.nativeElement._viewContainerRef = this.viewContainerRef;
this.template.elementRef.nativeElement.propName = "template";
}
createFormGroup(data: IOrderModel): FormGroup {
return new FormGroup({
OrderID: new FormControl(data.OrderID, Validators.required),
CustomerID: new FormControl(data.CustomerID, Validators.required)
});
}
ngOnInit(): void {
this.data = employeeData;
this.childGrid = {
dataSource: orderDatas,
editSettings: {
allowEditing: true,
allowAdding: true,
allowDeleting: true,
mode: "Dialog",
template: this.template
},
toolbar: ["Add", "Edit", "Delete"],
queryString: "EmployeeID",
load() {
this.registeredTemplate = {}; // set registertemplate value as empty in load event
},
columns: [
{
field: "OrderID",
headerText: "Order ID",
textAlign: "Right",
width: 120,
isPrimaryKey: true
},
. . . . . . . .
}
}
export interface IOrderModel {
OrderID?: number;
CustomerID?: string;
}
[app.component.html]
<ng-template #childTemplate let-data>
<div [formGroup]="orderForm">
. . . . . . . .
</div>
</ng-template>
|