本文主要是介绍WTM(ASP.NET Core)自定义列表按钮动作,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
WTM具有强大的代码生成器,可以帮助开发者自动生成增删查改代码和对应的操作视图,十分方便。但是,实际情况下,咱们需要额外开发一些功能来满足客户的使用需求。那么就需要额外添加一些按钮来满足需求。
咱们使用代码生成器,的默认按钮。
protected override List<GridAction> InitGridAction(){return new List<GridAction>{this.MakeStandardAction("School", GridActionStandardTypesEnum.Create, "新建","", dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.Edit, "修改","", dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.Delete, "删除", "",dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.Details, "详细","", dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.BatchEdit, "批量修改","", dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.BatchDelete, "批量删除","", dialogWidth: 800),this.MakeStandardAction("School", GridActionStandardTypesEnum.Import, "导入","", dialogWidth: 800),this.MakeStandardExportAction(null,false,ExportEnum.Excel)};}
那么自定义的按钮应该怎么写呢?
protected override List<GridAction> InitGridAction()
{var actions = new List<GridAction>{//调用页面上的名为test(ids,datas)的js方法this.MakeAction(null,null,"ScriptButton",null, GridActionParameterTypesEnum.NoId).SetOnClickScript("test"),//默认弹出对话框,并在每行显示按钮。通过whereStr指定将当前数据的ModelName字段的值拼接到url中,通过SetQueryString将固定的字符串拼到url中//下面这个语句最终访问的url为 : /_Admin/ActionLog/Details?id=xxx&ModelName=xxx&a=1this.MakeAction("ActionLog","Details","详情(Dialog)","Details dialog", GridActionParameterTypesEnum.SingleId,"_Admin",whereStr:x=>x.ModuleName).SetShowInRow(true).SetQueryString("a=1"),//设置IsRedirect和ShowDialog为true,弹出新浏览器窗口,并在每行显示按钮this.MakeAction("ActionLog","Details","详情(新窗口)","Details new window", GridActionParameterTypesEnum.SingleId,"_Admin").SetShowDialog(true).SetIsRedirect(true).SetShowInRow(true).SetQueryString("a=2"),//设置IsRedirect为true,ShowDialog为false,在本窗口或tab页上显示,并在每行显示按钮this.MakeAction("ActionLog","Details","详情(本窗口)","Details new window", GridActionParameterTypesEnum.SingleId,"_Admin").SetShowDialog(false).SetIsRedirect(true).SetShowInRow(true).SetQueryString("a=3"),};return actions;
}
SetIsRedirect=false,ShowDialog=true | 弹出模式对话框展现页面 |
SetIsRedirect=false,ShowDialog=false | 不弹出任何页面,只是在后台调用方法并执行方法返回的js |
SetIsRedirect=true,ShowDialog=true | 打开新的浏览器窗口显示页面 |
SetIsRedirect=true,ShowDialog=false | 在当前页或者显示页面,如果是Tab模式则在新Tab页上显示 |
SetOnClickScript | 如果设置了OnClickScript,则框架运行指定的js方法 |
SetShowInRow(true) | 按钮在每行的操作列上都显示 |
SetHideOnToolBar(true) | 按钮不在列表上方显示 |
点击数据表格某列跳转URL(带弹窗)
this.MakeGridHeader(x => x.Name).SetFormat((a,b)=>{string re = UIService.MakeDialogButton(ButtonTypesEnum.Link,$"/CURD/ReportForm/Details?ID={a.ID}&date={a.CurrentMonth}",a.Name ,800,null);//string re = $"<a href='/CURD/ReportForm/Details?ID={a.ID}&date={a.CurrentMonth}' target='_blank'>{a.Name }</a>";return re;}),
这篇关于WTM(ASP.NET Core)自定义列表按钮动作的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!