AutocompleteTextbox
Textbox + autocomplete suggestion — gợi ý realtime khi user gõ.
Source:
Core/Components/AutocompleteTextbox.cs· ComType:AutocompleteTextbox
Cấu hình
ComType: AutocompleteTextbox
FieldName: Address
Reference: Address # entity gợi ý
DataSourceFilter: ?$filter=Active eq true # bắt buộc đủ "?$filter="
Template: "{Street}, {City}" # format hiển thị item
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property entity bind value text (string). |
Reference | Type entity nguồn suggestion. |
RefName | Tên entity nguồn dạng string. |
DataSourceFilter | OData filter đủ ?$filter=... cho list suggestion. |
Query | Custom SQL/OData query. |
Template | String format hiển thị mỗi suggestion ("{Code} - {Name}"). |
FormatData | Format hiển thị value sau khi chọn. |
FormatEntity | Format toàn bộ entity đã chọn. |
GroupFormat | Format header group trong dropdown nếu IsPivot=true. |
GroupReferenceName | Tên field group trong reference. |
IsPivot | True → group suggestion theo field. |
ShowLabel | True → render <label> cạnh widget. |
UpperCase | True → uppercase value khi blur. |
PlainText | True → bỏ URL-encode 6 ký tự đặc biệt (+ / ? # & '), lưu raw. |
AutoFit | True → input co giãn theo nội dung. |
ChildStyle | Inline CSS style trên <input> element. |
Events | JSON map event → method C# (Change, Input, KeyDown, Click, FocusIn, …). |
Events kích hoạt
| Event | Method signature |
|---|---|
change | (entity, matched) |
input | (entity, matched) |
focusin | (entity, matched) |
focusout | (entity, matched) |
keydown | (entity, matched) |
click | (entity, matched) |
scroll | (entity, matched) |
matched là item gợi ý đang highlight (có thể null khi user gõ tự do).
Khi nào dùng
- Field tự do nhưng có gợi ý (địa chỉ, số điện thoại đã có sẵn, mã sản phẩm, …).
- Không bắt buộc user chọn từ list — họ vẫn gõ tay được.
Tip
Templatelà string format có placeholder{FieldName}.- Dùng AutocompleteTextarea cho nhiều dòng.