Known是基于C#和Blazor开发的前后端分离快速开发框架,开箱即用,跨平台,一处代码,多处运行。
如果对您有帮助,点击⭐Star⭐关注 ,感谢支持开源!
1. DataGrid功能
//同步导入
public void Import() => ShowImport(Name, typeof(TItem), false);
//异步导入
public void Import() => ShowImport(Name, typeof(TItem));
//SetData
grid?.SetData(new List<TItem>());
2. Upload组件
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Field<Upload>("附件:", "Upload")
.Set(f => f.IsButton, true)
.Set(f => f.ButtonText, "导入附件")
.Build();
}
3. KCConfig配置
//在项目初始化方法中加入如下代码
internal static void Initialize()
{
...
//该行需在KCConfig.AddWebPlatform之后添加才能覆盖ProductId
KCConfig.ProductId = GetProductId();
}
private static string GetProductId()
{
var id = "这里定义您的ID";
return $"PM-{Config.AppId}-{id:000000}";
}
4. Loading组件
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Button("提交", Callback(OnLoading), StyleType.Primary);
}
private void OnLoading()
{
UI.ShowLoading("数据提交中..."); //显示Loading
Task.Run(() =>
{
Thread.Sleep(2000);
UI.CloseLoading(); //关闭Loading
});
}
5. KRConfig配置
//在前端初始化方法中加入如下代码
internal static void Initialize()
{
KRConfig.IsEditCopyright = false; //不允许修改版权和许可
KRConfig.Copyright = "定义你的版权信息";
KRConfig.SoftTerms = "定义你的许可信息";
}
6. Prompt组件
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.Button("处理", Callback(OnPrompt), StyleType.Primary);
}
private void OnPrompt()
{
UI.Prompt("异常处理", new(300, 200), builder =>
{
builder.Field<TextArea>("原因", "Reason", true).Build();
},
data =>
{
//提交数据
UI.CloseDialog();
});
}