AntdUI 表格支持把单元格值设置为特殊对象,以显示文本、徽标、标签、图片、链接、按钮、开关、进度条等。复杂单元格通常配合 AntdUI.AntItem(key,value) 行数据使用。
CellText(text):带颜色、前后缀图标的文本。CellBadge(state,text):徽标状态,适合“在线/离线/处理中”。CellTag(text,type):标签,适合分类、状态标签。CellLink(id,text):链接文字。CellButton(id,text,type):按钮,继承 CellLink。CellProgress(value):进度条,value 范围通常为 0 到 1。CellSwitch(checked):开关。CellCheckbox(text,checked) / CellRadio(text,checked):复选/单选单元格。CellImage(image):图片或 SVG 图片。var text = AntdUI.CellText("已完成");
text.Fore = 0xFF008000;
var badge = AntdUI.CellBadge(AntdUI.TState.Success,"在线");
var tag = AntdUI.CellTag("VIP",AntdUI.TTypeMini.Primary);
var progress = AntdUI.CellProgress(0.65);
progress.Shape = AntdUI.TShape.Round;
.NET 的
System.Drawing.Color在 aardio 中就是0xAARRGGBB数值,传给 .NET 颜色属性时会自动转换;不需要调用System.Drawing.Color.FromArgb(...)或额外包装。
同一单元格可放多个 CellLink / CellButton。非空 aardio 数组可按目标参数类型自动转换为 CellLink[],通常不必手工创建 CLR 数组。
var buttons = [
AntdUI.CellButton("edit","编辑",AntdUI.TTypeMini.Primary),
AntdUI.CellLink("delete","删除")
];
var row = [
AntdUI.AntItem("name","张三"),
AntdUI.AntItem("ops",buttons)
];
处理按钮点击:
grid.CellButtonClick = function(sender,e){
select(e.Btn.Id) {
case "edit" {
winform.msgbox("编辑第 " + e.RowIndex + " 行");
}
case "delete" {
winform.msgbox("删除第 " + e.RowIndex + " 行");
}
}
}
import dotNet.AntdUI;
import dotNet; // 本例仅用于 dotNet.createArrayList()
var row = [
AntdUI.AntItem("name","李四"),
AntdUI.AntItem("state",AntdUI.CellBadge(AntdUI.TState.Processing,"处理中")),
AntdUI.AntItem("tag",AntdUI.CellTag("NEW",AntdUI.TTypeMini.Success)),
AntdUI.AntItem("progress",AntdUI.CellProgress(0.3))
];
var rows = dotNet.createArrayList();
rows.Add(row);
grid.DataSource = rows;
Text:显示文本。Fore / Back:文字与背景颜色。Font:字体。PrefixSvg / SuffixSvg:前缀/后缀 SVG。SetText(...)、SetFore(...)、SetBack(...)、SetPrefix(...)、SetSuffix(...)。Text:显示文本。State:状态,常用 AntdUI.TState.Success/Processing/Error/Warn/Default。Fore / Fill:文字与填充颜色。SetState(...)、SetText(...)。Text:标签文本。Type:类型,常用 AntdUI.TTypeMini.Primary/Success/Error/Warn/Info/Default。Fore / Back:文字与背景颜色。BorderWidth:边框宽度。Id:业务标识,按钮点击事件里常用。Text:显示文本。Enabled:是否启用。Tooltip:提示文本。CellButton.Type:按钮类型。CellButton.Ghost / Shape / IconSvg / Loading:按钮外观与状态。SetBorder()、SetGhost()、SetIcon(...)、SetType(...)、SetLoading(...)。Checked:选中状态。Enabled:是否启用。AutoCheck:点击时是否自动切换。Text / CheckedText / UnCheckedText:显示文本。CellLink[]、CellImage[]、AntItem[] 这类参数通常可直接传非空 aardio 数组,例如 [AntdUI.AntItem("name","张三")]。[] 无法推断 .NET 元素类型;此时才需要 dotNet.createArray(type,0) 或指定泛型集合。netObjArray[1] 会映射到 CLR 第 0 项;只有直接调用 .SetValue(value,0) / .GetValue(0) 这类 .NET 方法时才使用 0-based 索引。Table.CellButtonClick,不要用 CellClick 判断鼠标位置。CellButton 继承 CellLink,所以 CellButton 可放进 CellLink[]。DataTable;只有需要复杂单元格时再使用 AntItem[] 或对象列表。