Button
Button generic — wire vào method C# qua `Events`, hoặc dùng `Name` đặc biệt để Core auto-bind.
Source:
Core/Components/Button.cs· ComType:Button
Cấu hình
ComType: Button
Name: btnExport # Name = btnSave/btnCancel/... → auto bind
Label: Xuất Excel
Icon: fas fa-file-excel
ClassName: btn btn-success
HotKey: Ctrl+E
Events: '{"click": "ExportExcel"}'
Field DB dùng
| Field | Vai trò |
|---|---|
Label | Text hiển thị trên button. |
Icon | Icon class (FontAwesome fas fa-save) hoặc path file (icons/save.png). |
ClassName | CSS class (Bootstrap btn btn-primary, btn-success, …). |
Style | Inline CSS style (width: 200px; margin-left: 8px). |
Events | JSON map {"click": "MethodName"} để wire click → method C# trên class TabEditor. |
FieldName | Property bind (rare — dùng khi button thay đổi 1 field cụ thể). |
Query | Tham số query truyền vào method (rare). |
Id | DOM ID (rare — Core auto-generate). |
Events kích hoạt
| Event | Method signature |
|---|---|
click | (entity, this) |
Tham số 2 là chính Button instance.
public class CustomerListBL : TabEditor
{
public CustomerListBL() : base(nameof(Customer)) { }
public async Task ExportExcel(object entity, object btn)
{
Spinner.AppendTo(Document.Body);
try { /* export logic */ }
finally { Spinner.Hide(); }
Toast.Success("Đã xuất Excel");
}
}
Name đặc biệt — Core auto-bind
Set Name = 1 trong các string sau, không cần Events:
Name | Hành vi mặc định |
|---|---|
btnSave | Gọi Save(Entity) của TabEditor/PopupEditor. |
btnCancel | Đóng tab/popup (prompt nếu dirty). |
btnPrint | In report bound. |
btnPreview | Print preview. |
btnSend | Save + transition StatusId. |
btnApprove | Approval transition. |
btnReject | Rejection transition. |
Tip
HotKey(vdCtrl+S,F5,Esc) auto-wire phím tắt — không cần code thêm.Icondùng FontAwesome class hoặc path file (icons/save.png).ClassNamethêm class CSS Bootstrap (btn-success,btn-danger, …).