Core Docs

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

FieldVai trò
FieldNameProperty của entity (DateTime?).
FormatDataFormat hiển thị — dạng "{0:format}", code tự strip {0:} để lấy format string. Vd "{0:dd/MM/yyyy}", "{0:dd/MM/yyyy HH:mm}".
PrecisionSố chữ số thập phân thời gian (chỉ dùng nếu cấu hình thời gian phụ).
FocusSearchTrue → auto focus picker khi tab đầu vào field.
EventsJSON map event → method C# (Change).
PlainTextTrue → render plain text khi readonly.

Events kích hoạt

EventMethod signature
change(entity, value, this)

valueDateTime? đã 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 code dp.Value = null.
  • Combine với MonthBox khi chỉ cần chọn tháng/năm.

Core Docs · Astro · Core.API/wwwRoot/docs