2

在我的视图页面中,我有一个按钮。当我单击按钮时,我想让窗口打开。该窗口有一些标签条,在标签条中我想显示一个网格。kendo UI 允许我这样做吗?

 @(Html.Kendo().Window()
.Name("window")
.Title("About Alvar Aalto")
.Content(@<text>  
 @(Html.Kendo().TabStrip()
      .Name("tabstrip")
      .Items(tabstrip =>
      {
          tabstrip.Add().Text("Paris")
              .Selected(true)
              .Content(@<text>
                <div class="weather">
                    <h2>17<span>&ordm;C</span></h2>
                    <p>Rainy weather in Paris.</p>
                </div>
                <span class="rainy">&nbsp;</span>
              </text>);

          tabstrip.Add().Text("New York")
              .Content(@<text>
@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
    .Name("grid")
    .Columns(columns =>
    {
        columns.Bound(c => c.ContactName).Width(140);
        columns.Bound(c => c.ContactTitle).Width(190);
        columns.Bound(c => c.CompanyName);
        columns.Bound(c => c.Country).Width(110);
    })
    .HtmlAttributes(new { style = "height: 380px;" })
    .Scrollable()
    .Groupable()
    .Sortable()
    .Pageable(pageable => pageable
         .Refresh(true)
        .PageSizes(true)
        .ButtonCount(5))
         .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Customers_Read", "Grid"))
    )
   )
  </text>);
      })
     )
  </text>)
 .Draggable()
 .Resizable()
 .Width(600)
 .Actions(actions => actions.Pin().Minimize().Maximize().Close())
 .Events(ev => ev.Close("onClose"))
  )
4

2 回答 2

3

对你来说最好的事情就是把它分成一些局部视图,让你的生活变得不那么复杂。

剑道之窗

@(Html.Kendo().Window()
    .Name("window")
    .Title("About Alvar Aalto")
    .Content(@Html.Partial("_TabStrip").ToHtmlString())
    .Draggable()
    .Resizable()
    .Width(600)
    .Actions(actions => actions.Pin().Minimize().Maximize().Close())
    .Events(ev => ev.Close("onClose"))

)

_TabStrip(部分视图)

@(Html.Kendo().TabStrip()
.Name("tabstrip")
.SelectedIndex(0)
.Items(items =>
    {
        items.Add()
            .Text("Paris")
            .Content(@Html.Partial("_Weather").ToHtmlString());
        items.Add()
            .Text("New York")
            .Content(@Html.Partial("_Grid").ToHtmlString());
    })    
)

_天气(部分视图)

 <div class="weather">
     <h2>17<span>&ordm;C</span></h2>
     <p>Rainy weather in Paris.</p>
  </div>
 <span class="rainy">&nbsp;</span>

_Grid(局部视图)

@(Html.Kendo().Grid<Kendo.Mvc.Examples.Models.CustomerViewModel>()
    .Name("grid")
    .Columns(columns =>
        {
        columns.Bound(c => c.ContactName).Width(140);
        columns.Bound(c => c.ContactTitle).Width(190);
        columns.Bound(c => c.CompanyName);
        columns.Bound(c => c.Country).Width(110);
    })
    .HtmlAttributes(new { style = "height: 380px;" })
    .Scrollable()
    .Groupable()
    .Sortable()
    .Pageable(pageable => pageable
         .Refresh(true)
         .PageSizes(true)
         .ButtonCount(5))
         .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("Customers_Read", "Grid"))
        )
   )

使用局部视图分离内容将使您能够更灵活地使用 Kendo 控件相互拉取内容,而不必担心 <text> 块是否正确。

于 2014-04-12T03:04:06.090 回答
0

网格事件等被定位到它们各自的局部视图,就像它是一个完整视图一样。部分视图可以将自己的模型与父视图分开,从而在 mvc 应用程序中提供更大的灵活性。

于 2014-04-12T13:36:53.647 回答