小编Did*_*era的帖子

如何使用动态生成的对象作为CodeEffects生成器的数据源

我们正在使用这个组件www.codeeffects.com,它允许我们根据对象属性创建业务规则。

视图的html是这样的:

@{
    ViewBag.Title = "Post Example";

    Html.CodeEffects().Styles()
        .SetTheme(ThemeType.Gray)
        .Render();
}
@using (Html.BeginForm("Evaluate", "Post", FormMethod.Post))
{
    <div class="area">
        <h1 class="title">Post Example</h1>
        <div style="margin-top:10px;">
            <span>Info:</span>
            <span style="color:Red;">@ViewBag.Message</span>
        </div>
        <div style="margin-top:10px;">
            @{
    Html.CodeEffects().RuleEditor()
        .Id("ruleEditor")
        .SaveAction("Save", "Post")
        .DeleteAction("Delete", "Post")
        .LoadAction("Load", "Post")
        .Mode(RuleType.Execution)
        .ContextMenuRules(ViewBag.ContextMenuRules)
        .ToolBarRules(ViewBag.ToolBarRules)
        .Rule(ViewBag.Rule)
        .Render();
            }
        </div>
    </div>
    <div class="area">
        <h1 class="title" style="margin-top:20px;">Rule Test Form</h1>
        @{
    Html.RenderPartial("_PatientForm");
        }
    </div>
}
@{
    Html.CodeEffects().Scripts().Render();
}
Run Code Online (Sandbox Code Playgroud)

控制器中的索引操作如下:

 [HttpGet]
        public ActionResult Index()
        {
            ViewBag.Rule = RuleModel.Create(typeof(Patient));
            return View();
        }
Run Code Online (Sandbox Code Playgroud)

Patient 类是这样的:

// External methods …
Run Code Online (Sandbox Code Playgroud)

c# asp.net reflection asp.net-mvc system.reflection

5
推荐指数
1
解决办法
929
查看次数

标签 统计

asp.net ×1

asp.net-mvc ×1

c# ×1

reflection ×1

system.reflection ×1