ImageUploader
Upload image (1 hoặc nhiều) — paths lưu vào string field của entity, phân cách `;`.
Source:
Core/Components/ImageUploader.csComponentTypetrong DB:Image(alias chính). Cũng dùng đượcImageUploaderqua reflection.
Cấu hình
ComType: Image # alias chính cho ImageUploader
FieldName: Attachments
Label: File đính kèm
ShowLabel: true
Field DB dùng
| Field | Vai trò |
|---|---|
FieldName | Property entity bind chuỗi paths file (string, các paths cách bởi ;). |
Label | Text label hiển thị. |
DataSourceFilter | OData filter ?$filter=... (nếu cần lookup file metadata). |
Events | JSON map {"change": "OnUploaded"} để hook handler. |
ChildStyle | Inline CSS cho thumbnail container. |
IsRealtime | True → push update qua WebSocket khi file mới upload. |
Precision | Precision setting (rare). |
VirtualScroll | True → virtual scroll khi nhiều file. |
UpperCase | True → uppercase tên file display. |
PlainText | True → text display thay vì thumbnail preview. |
ComponentGroupId | Section ID chứa uploader (auto-set). |
Id | DOM ID (auto-set). |
Events kích hoạt
| Event | Method signature |
|---|---|
change | (entity) |
Fire sau mỗi lần upload xong (1 file hoặc batch).
public void OnAttachmentsChanged(object entity)
{
var inv = (Invoice)entity;
Toast.Small("Đã upload, paths: " + inv.Attachments);
}
Behavior
- POST file lên endpoint FTP/file → backend trả về path string.
- Nhiều paths concat bởi
;(vd"img1.png;img2.jpg"). - Drag & drop file vào component cũng work.
- Click ô → mở dialog browse file.
Tip
- Mở dialog từ code:
imgUploader.OpenFileDialog(eventArg)— pattern thựcDriverContainerDetailBL.cs. - Hiển thị thumbnail tự động cho file image; file khác render link.