Bỏ qua, đến nội dung

FAQ

Schema trả về thiếu children?

Nguyên nhân: getJsonSchema build tree từ closure table. Nếu uiSchemaTreePath thiếu record cho một cặp ancestor-descendant, child node sẽ không xuất hiện.

Giải pháp:

  1. Kiểm tra uiSchemaTreePath có đủ records không: SELECT * FROM uiSchemaTreePath WHERE ancestor = '<parent-uid>'.
  2. Nếu thiếu, dùng insert hoặc insertAdjacent để re-attach child.
  3. Gọi clearCache sau khi sửa data trực tiếp.

insertAdjacent với position nào cho đúng?

PositionKết quảVí dụ
beforeBeginTrước node tham chiếu (cùng level)Thêm column trước column "Tên"
afterBeginĐầu children của nodeThêm block đầu tiên trong Grid
beforeEndCuối children của nodeThêm block cuối cùng trong Grid
afterEndSau node tham chiếu (cùng level)Thêm column sau column "Tên"

Nếu nhầm beforeBegin/afterEnd (cùng parent) với afterBegin/beforeEnd (thành child), schema sẽ nằm sai level trong cây.

ServerHook không chạy khi xóa collection?

Hook onCollectionDestroy chỉ trigger khi:

  1. Schema node có record trong uiSchemaServerHooks với type = 'onCollectionDestroy'collection = '<tên collection>'.
  2. Collection bị xóa qua API chuẩn (trigger afterDestroy).

Kiểm tra: SELECT * FROM uiSchemaServerHooks WHERE type = 'onCollectionDestroy' AND collection = '<tên>'.

Template tạo xong nhưng không thấy trong danh sách?

uiSchemaTemplates:list filter theo componentName nếu có query param. Kiểm tra:

  1. Template đã lưu thành công: SELECT * FROM uiSchemaTemplates WHERE key = '<key>'.
  2. componentName có khớp filter client đang gửi không.
  3. uid FK trỏ đúng schema gốc (schema gốc phải tồn tại).

Button hiển thị cho role không mong muốn?

Button visibility kiểm soát qua uiButtonSchemasRoles:

  • Nếu button schema records trong bảng junction → chỉ role trong danh sách mới thấy.
  • Nếu không có record nào → tất cả role đều thấy (default visible).

Để ẩn button khỏi role cụ thể: đảm bảo junction chỉ chứa role được phép.

clearAncestor khác remove thế nào?

ActionNodeDescendantsClosure paths
removeXóaXóa cascadeXóa
clearAncestorGiữGiữXóa ancestor links (node trở thành root riêng)

Dùng clearAncestor khi muốn detach node tạm thời (VD: move sang cây khác sau). Dùng remove khi muốn xóa vĩnh viễn.

Sửa schema trực tiếp trong DB có an toàn không?

Không khuyến khích. Nếu bắt buộc:

  1. Sửa uiSchemas.schema JSON — đảm bảo format hợp lệ.
  2. Phải gọi clearCache sau khi sửa (cache không tự invalidate).
  3. Không sửa uiSchemaTreePath thủ công — closure table rất dễ inconsistent.
  4. ServerHooks sẽ không trigger khi sửa trực tiếp DB.