Core Docs

Select2

Dropdown — chọn 1 entity từ list nhỏ-tĩnh-tương-đối (status, loại). Load tất cả options khi render.

Source: Core/Components/Select2.cs · ComType: Select2

Cấu hình

ComType:           Select2
FieldName:         StatusId
Reference:         Status
DataSourceFilter:  ?$filter=Active eq true     # bắt buộc đủ "?$filter="

Field DB dùng

FieldVai trò
ReferenceType của entity nguồn (vd Status, Country).
RefNameTên entity nguồn dạng string ("Status") — backup cho Reference.
DataSourceFilterOData querystring đủ ?$filter=... để filter list options.
FormatDataString format hiển thị mỗi option (vd "{Code} - {Name}").
FocusSearchTrue → auto focus search box bên trong dropdown khi mở.
UpperCaseTrue → text option hiển thị uppercase.

Events

Không fire event riêng — value sync vào entity.<FieldName> qua bind. Nếu cần phản ứng khi user đổi → dùng EditableComponent base event Change (tham khảo Component.Events JSON kèm method có signature (entity, newValue, oldValue, parent)).

Behavior

  • Gọi Client.GetRawList<Reference>(DataSourceFilter) 1 lần khi render.
  • Lưu id (int) của entity được chọn vào entity.<FieldName>.
  • Display text từ field Name / Label của entity tham chiếu.

Khi nào dùng

✅ List option < 50, ổn định trong session (status, loại, vai trò).

❌ List > 50 → dùng SearchEntry có type-ahead.

Tip

Core Docs · Astro · Core.API/wwwRoot/docs