Trang tài liệu Trí Nam

Debug là việc khó gấp đôi code. Nếu viết code thông minh quá mức, bạn sẽ không đủ thông minh để debug nó

ReferenceTextControlSchema

Estimated reading: 3 minutes 368 views

Hình ảnh / Demo

Mục đích

Dùng để tạo 1 control có value dựa theo 1 trường dữ liệu lấy thêm của Control khác.

Cách dùng

Import

Import vào đầu file .ts cần sử dụng

				
					import { ReferenceTextControlSchema } from 'tnx-shared';
				
			

Cách dùng cơ bản

ReferenceTextControlSchema được thêm vào trong this.setting.schema khi khởi tạo form.

				
					...
ngOnInit() {
...
this.setting.schema = [
   new DropdownControlSchema({
        field: 'idNgachVienChuc',
        label: 'Ngạch hiện tại',
        baseService: this._dmNgachLuongService,
        fieldPlus: 'idBac',  // trường lấy thêm lúc gọi Api
   }),
   
   // Khi dropdown được chọn, response trả về sẽ kèm theo trường idBac sau đó
   // gán giá trị này vào control có field là idBac
   new ReferenceTextControlSchema({
        field: 'idBac',
        label: 'Bậc hiện tại',
        baseService: this._dm_BacLuongService,
        disabled: true,
        mdWidth: 3,
    }),
  ...
]
...
}
...
				
			

Thuộc tính

Sự kiện

				
					
new ReferenceTextControlSchema({
    field: 'idNgachVienChuc',
    label: 'Ngạch hiện tại',
    baseService: this._dmNgachLuongService,
    fieldPlus: 'code',
    funcGetLabel: item => `${item.ten} (${item.code})`,
    disabled: true,
    mdWidth: 3,
    onChanged: (eventData: EventData) => {
        console.log(eventData);
        if (this.model.data.property || <>) {
            evt.formControls['other control name'].hidden = true;
        } else {
            evt.formControls['other control name'].hidden = false;
        }
    },
    // nếu là thành viên ngoài trường thì hiện, không phải thì ẩn đi
    hiddenCheck: (rootModel, currentNode) => {
        return !currentNode.parentNode.parentModel.isThanhVienNgoaiTruong;
    },
}),

				
			
CONTENTS