MultipleSearchEntry
Multi-select picker — chọn nhiều entity, render dạng tag remove được.
Source:
Core/Components/MultipleSearchEntry.csComponentTypetrong DB:DropdownvớiPrecision >= 2(Core auto pickMultipleSearchEntrythay vìSearchEntry). Cũng dùng đượcMultipleSearchEntryqua reflection.
Cấu hình
ComType: Dropdown # alias; Precision >= 2 → MultipleSearchEntry
Precision: 2
FieldName: TagIds
RefName: Tag
DefaultVal: "[]" # mặc định empty list
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property entity bind list FK (vd List<int> TagIds). |
RefName | Tên entity tham chiếu (vd "Tag"). |
LocalData | Inline JSON list options → bypass API. |
DefaultVal | Giá trị mặc định (vd "[]" cho empty list). |
Events | JSON map event → method C# (Change). |
Events kích hoạt
| Event | Method signature |
|---|---|
change | (entity, listValues, oldList) |
listValues / oldList là List<object> — danh sách selection mới / cũ.
public void OnTagsChanged(object entity, object newList, object oldList)
{
var tags = (newList as IEnumerable<object>)?.ToList();
Toast.Small("Đã chọn " + (tags?.Count ?? 0) + " tag");
}
Behavior
- Bind giá trị
List<int>vàoentity.<FieldName>(hoặc CSV tuỳ format). - Render selected items thành tag với nút “x” để remove.
Tip
- Set
DefaultVal: "[]"để khởi tạo empty list, tránh null. - Dùng cho many-to-many (Tag, Permission, …) hoặc tag-like collection.