Datepicker
Picker ngày — bind `DateTime?`. Hỗ trợ format hiển thị qua `FormatData`.
Source:
Core/Components/Datepicker.cs· ComType:Datepicker
Cấu hình
ComType: Datepicker
FieldName: InvoiceDate
Label: Ngày
ShowLabel: true
FormatData: "{0:dd/MM/yyyy}" # Datepicker tự strip "{0:" và "}" → "dd/MM/yyyy"
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property của entity (DateTime?). |
FormatData | Format hiển thị — dạng "{0:format}", code tự strip {0: và } để lấy format string. Vd "{0:dd/MM/yyyy}", "{0:dd/MM/yyyy HH:mm}". |
Precision | Số chữ số thập phân thời gian (chỉ dùng nếu cấu hình thời gian phụ). |
FocusSearch | True → auto focus picker khi tab đầu vào field. |
Events | JSON map event → method C# (Change). |
PlainText | True → render plain text khi readonly. |
Events kích hoạt
| Event | Method signature |
|---|---|
change | (entity, value, this) |
value là DateTime? đã chọn. Tham số 3 là chính component Datepicker.
public void OnDateChanged(object entity, object value, object dp)
{
var date = value as DateTime?;
if (date.HasValue) Toast.Small("Ngày: " + date.Value.CustomFormat("dd/MM/yyyy"));
}
Tip
FormatData = "{0:dd/MM/yyyy}"cho Việt Nam. Khác locale tự đổi format string trong dấu{0:...}.- Để clear field → user bấm
Esc+Enter, hoặc codedp.Value = null. - Combine với MonthBox khi chỉ cần chọn tháng/năm.