Textbox
Input text 1 dòng — bind giá trị string vào property của entity.
Source:
Core/Components/Textbox.csComponentTypetrong DB:Input(alias chính) ·Password(Textbox vớiPassword=true) ·Textbox(qua reflection — cũng được).
Cấu hình
ComType: Input # alias = Textbox; dùng "Password" cho ô mật khẩu
FieldName: Code
Label: Mã khách hàng
ShowLabel: true
UpperCase: true
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property của entity bind vào input. Hỗ trợ dotted path (Address.Street). |
Label | Text label hiển thị (cùng ShowLabel). |
ShowLabel | True → render <label> cạnh input. |
UpperCase | True → auto chuyển string sang chữ hoa khi blur. |
FormatData | Template áp lên value của field. Vd "{Code}", "MÃ: {0}". Engine: Utils.FormatEntity. |
FormatEntity | Template áp lên toàn bộ entity, ghép nhiều field. Vd "{Code} - {Name}". Override FormatData nếu cả 2 set. |
RefName | Tên entity tham chiếu (khi field bind tới FK string). |
Events | JSON map {event-type: methodName} để wire vào method C# (Change, Input). |
Migration | Script migration nội bộ (rare — chỉ admin form). |
PlainText | True → bỏ qua URL-encode 6 ký tự đặc biệt (+ / ? # & '), lưu raw. |
ChildStyle | Inline CSS style apply lên <input> element bên trong. |
AutoFit | True → input co giãn theo độ dài nội dung. |
Events kích hoạt
| Event | Method signature | Khi nào fire |
|---|---|---|
change | (entity, newValue, oldValue, parent) | Blur hoặc Enter, value đã thay đổi. |
input | (entity) | Mỗi keystroke (chỉ khi cần realtime). |
{ "change": "OnCodeChanged" }
public class CustomerDetailBL : PopupEditor
{
public CustomerDetailBL() : base(nameof(Customer)) { }
public void OnCodeChanged(object entity, object newVal, object oldVal, object parent)
{
Toast.Small("Mã đã đổi: " + newVal);
}
}
Tip
UpperCase = true→ auto chuyển sang chữ hoa khi blur.- URL-encode mặc định bật (KHÔNG phải HTML encode). Trước khi lưu, 6 ký tự
+ / ? # & 'bị encode thành%2B %2F %3F %23 %26 %27(xemUtils.SpecialChar). Khi đọc, decode lại. Mục đích: tránh các ký tự này phá OData querystring (?$filter=Code eq 'ACME&Co'thì&bị hiểu nhầm là separator). - Tắt encode bằng
Feature.IgnoreEncode = true(lưu raw — chấp nhận rủi ro nếu giá trị xuất hiện trong filter URL). - Password field: set
Password = truequa property C# (không có field DB tương ứng).