Number
Input số nguyên / thập phân — bind decimal/int. Cấu hình `Precision` cho số chữ số thập phân.
Source:
Core/Components/Number.cs· ComType:Number
Cấu hình
ComType: Number
FieldName: Quantity
Label: Số lượng
ShowLabel: true
Precision: 2 # 2 chữ số thập phân
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property của entity bind vào (int, decimal, double). |
Precision | Số chữ số thập phân hiển thị (vd 2 cho money). Giá trị raw vẫn full precision. |
Events | JSON map event → method C# (Change, Input). |
Query | OData/SQL query nội bộ (rare — cho calculated fields). |
FormatData | Template {<FieldName>:format} áp lên value. Vd "{Amount:N2}", "{Total:N0} VND". |
FormatEntity | Template {FieldName} áp lên toàn entity (ghép nhiều field). |
CanCache | True → cache giá trị (dùng cho computed columns). |
AutoFit | True → input co giãn theo nội dung. |
PlainText | True → render plain (không format). |
ChildStyle | Inline CSS style apply lên <input> bên trong. |
Events kích hoạt
| Event | Method signature | Khi nào |
|---|---|---|
change | (entity, newValue, oldValue, parent) | Blur hoặc Enter, value đã đổi. |
input | (entity) | Mỗi keystroke. |
{ "change": "Recalculate" }
public void Recalculate(object entity, object newVal, object oldVal, object parent)
{
var line = (InvoiceLine)entity;
line.Total = line.Qty * line.Price;
this.FindComponentByName<Number>("Total")?.UpdateView();
}
Tip
Precisionchỉ chi phối hiển thị (format khi blur). Giá trị raw lưu vào entity vẫn làdecimalđầy đủ.- Để giới hạn min/max — set vào
Component.Validation(rule JSON:{"min": 0, "max": 999999}). Trước submitawait this.IsFormValid()sẽ tự check. AutoFit = true→ input co giãn theo nội dung.