Kendo widgets two level deep in Razor, inline markup blocks cannot be nested

前端 未结 1 1386
既然无缘
既然无缘 2021-01-06 00:06

I´m trying to implement Kendo widgets two level deep but the Razor engine keeps complaining: \"Inline markup blocks (@Content) cannot be nested. Only one level of inlin

1条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 00:35

    I think you probably need to use razor helper at any level. In your case, you probably need to put the grid in another RenderGrid() as shown below:

    @(Html.Kendo().TabStrip()
      .Name("tabStrip")
      .Items(tabstrip =>
      {
          tabstrip.Add().Text("Strip1")
              .Selected(true)
              .Content(@
                            @RenderPanelBar()
                        );
          tabstrip.Add().Text("Strip2")
              .Content(@
    
                        );
      })
      )
    
    @helper RenderPanelBar()
    {
    @(Html.Kendo().PanelBar()
          .Name("panelBar")
          .ExpandMode(PanelBarExpandMode.Single)
          .Items(panelbar =>
          {
              panelbar.Add().Text("panel1")
                  .Expanded(true)
                  .Content(@
                                @RenderGrid()
                            
                  );
              panelbar.Add().Text("panel2")
                  .Content(@
    //stuff abbreviated
    ); }) ) } @helper RenderGrid() { @(Html.Kendo().Grid() .Name("GroupGrid") .Columns(columns => { columns.Bound(c => c.GroupID).Hidden(); columns.Bound(c => c.Name); columns.Command(command => { command.Edit(); command.Destroy(); }); }) .ToolBar(toolbar => { toolbar.Create(); toolbar.Template(@ @RenderDropDown() ); }) .Editable(editable => editable.Mode(GridEditMode.InLine)) .Scrollable(s => s.Enabled(false)) .Selectable(s => s.Enabled(true).Mode(GridSelectionMode.Single)) .DataSource(dataSource => dataSource.Ajax() .Read(read => read.Action("Group_Grid_Read", "Home")) .Events(events => events.Error("error_handler")) .Model(model => model.Id(p => p.GroupID)) .Create(update => update.Action("EditingInline_Create", "Home")) .Update(update => update.Action("EditingInline_Update", "Home")) .Destroy(update => update.Action("EditingInline_Destroy", "Home"))) .Events(e => e.Change("onGroupGridChange").Save("GroupGrid_Save")) ) } @helper RenderDropDown() {
    @(Html.Kendo().DropDownList() .Name("categories") .OptionLabel("All") .DataTextField("CategoryName") .DataValueField("CategoryID") .AutoBind(false) .Events(e => e.Change("categoriesChange")) .DataSource(ds => { ds.Read("ToolbarTemplate_Categories", "Grid"); }) )
    }

    0 讨论(0)
提交回复
热议问题