【问题标题】:Kendo Tabstrip loading Grid with .Content works, .LoadContentFrom doesn't带有 .Content 的 Kendo Tabstrip 加载网格有效,.LoadContentFrom 无效
【发布时间】:2014-02-27 16:10:43
【问题描述】:

我有一个标签条在 2 个不同的选项卡中加载一个网格(相同的网格,相同的数据)。

    @(Html.Kendo().TabStrip()
    .Name("tabstrip")
    .Items(tabstrip =>
    {     
        tabstrip.Add().Text("Cycle Summary")
            .Content(@<text>@Html.Action("VQCycleSummary", "Sessions", new { id = Model.ID })</text>).Selected(true);
        tabstrip.Add().Text("Cycle Summary2")
            .LoadContentFrom("VQCycleSummary", "Sessions", new { id = Model.ID });


    })
)

网格:

@(Html.Kendo().Grid(Model)
  .Name("cycleGrid")
  .DataSource(ds => ds
      .Ajax()
      .Read(read => read.Action("VqCyclesSummary_Read", "Sessions", new {sessionId = ViewBag.SessionID}))
      .PageSize(100)
  )
  .Columns(columns =>
  {
      columns.Bound(c => c.TimeStampUTC).Format("{0: MM/dd/yyyy h:mm:ss tt}").Width(180);

      for (int i = 1; i <= ((int) ViewBag.MaxChannelNumber); ++i)
      {
          columns.Bound(string.Format("Channel{0}_DL", i)).Format("{0:N5}");
      }
      for (int i = 1; i <= ((int) ViewBag.MaxChannelNumber); ++i)
      {
          columns.Bound(string.Format("Channel{0}_UL", i)).Format("{0:N5}");
      }
      columns.Bound(c => c.GPS_Lat).Format("{0:N5}");
      columns.Bound(c => c.GPS_Long).Format("{0:N5}");
  })
  .Filterable()
  .Sortable()
  .Scrollable(c => c.Height(500)).Scrollable(c => c.Virtual(true)))

控制器:

public ActionResult VQCycleSummary(long id)
    {
    using (var context = new Entities())
    {
        short? max = context.TestDevices.Where(td => td.SessionID == id).Max(td => td.ChannelNumber);


        ViewBag.MaxChannelNumber = max.HasValue ? (int) max + 1 : 0;
        ViewBag.SessionID = id;
        return PartialView("VqCycleSummary");
    }
}

public ActionResult VqCyclesSummary_Read([DataSourceRequest] DataSourceRequest request, int sessionId)
{
    using (var context = new Entities())
    {
        var cycles = //get data

        DataSourceResult result = cycles.ToDataSourceResult(request);

        return Json(result);
    }
}

我看到数据在第一个网格上正确显示,但不是第二个。我确实看到两个网格的控制器都返回了数据。正在为第二个网格创建列,但未显示实际数据的行。

【问题讨论】:

    标签: asp.net-mvc data-binding kendo-ui kendo-grid asp.net-mvc-5


    【解决方案1】:

    以不同的方式命名您的网格。您不能有两个具有相同名称的小部件 - 它们在标记中用作 ID,因此第二个 Grid 的 jQUery 选择器将失败

    【讨论】:

    • 是否可以在加载网格时动态命名?
    • 使用一些 C# 逻辑在 cshtml 视图中执行此操作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多