0

我一直在尝试在各个地方为我在使用 Kendo UI 网格时遇到的问题寻求一些帮助。

我正在尝试做的事情

我想要做的是使用一个服务器绑定网格,该网格在一个标签条内的 2 行中使用模板,我想使用“LoadContentFrom”加载它以利用按需加载。除此之外,我需要在网格上实现排序。

我已经尝试过的

我尝试了很多方法来实现这一点,但都没有成功。为了暂时解决这个问题,我正在使用“内容”功能将数据加载到我的标签条中。不利的一面是,我所有标签条中的所有数据都会在页面加载时加载。这会导致页面加载速度变慢,并且每次单击列标题进行排序时,页面都会刷新。

摘要问题

所以我的问题是,是否有可能有一个使用“LoadContentFrom”方法的标签条,并在可以排序的标签条之一中有一个服务器绑定网格?

如果可能的话,有人能给我一个例子吗?

我的开发环境

我正在从事基于 MVC 4 的项目。我使用 VB.NET 作为我的编程语言。我很高兴有人使用 C# 提供答案。

我的代码现在的样子

下面是我现在拥有的代码示例。

标签条代码

`@Imports CommericalPortal.BusinessData.Entities
@Imports CommericalPortal.Web.Models.Entities
@imports CommericalPortal.Web.My.Resources
@ModelType Customer

@Code
    ViewBag.Settings.PageTitle = Model.OperatingName

    Dim lastSavedTabIndex As Integer
    If Request.Cookies("TabCustomersPolicySavedIndex") IsNot Nothing AndAlso IsNumeric(Request.Cookies("TabCustomersPolicySavedIndex").Value) Then
        lastSavedTabIndex = CInt(Request.Cookies("TabCustomersPolicySavedIndex").Value)
    Else
        lastSavedTabIndex = 1
    End If
End Code

@(Html.Kendo().TabStrip().Name("TabCustomers").SelectedIndex(lastSavedTabIndex) _
    .Items(Sub(actions)
                   actions.Add().Text(TabText.ContactInfoTab).Content(Html.Action("ByLocation", "Contacts", New With {.asPartial = True}).ToHtmlString)
                   actions.Add().Text(TabText.PoliciesTab).Content(Html.Action("ByLocation", "Policies", New With {.asPartial = True}).ToHtmlString)
                   actions.Add().Text(TabText.InvoicesTab).Content(Html.Action("ByLocation", "Invoices", New With {.asPartial = True}).ToHtmlString)
                   actions.Add().Text(TabText.ClaimsTab).Content(Html.Action("ByLocation", "Claims", New With {.asPartial = True}).ToHtmlString)
                   actions.Add().Text(TabText.BillingTab).Content(Html.Action("ForCustomer", "Billing", New With {.asPartial = True}).ToHtmlString)
           End Sub) _
    .Events(Sub(x)
                   x.Select("onSelect")
            End Sub)
    )

<script>
    function onSelect(e) {
        SetupTabStripToRememberActiveTabBetweenPageCalls 
("TabCustomers", "TabCustomersPolicySavedIndex");
    }
</script>`

标签条内容代码(网格)

`@ModelType ilist(of CommericalPortal.BusinessData.Entities.PACInformation)'
@imports CommericalPortal.Web

@(Html.Kendo.Grid(Model).Name("DisplayPAC") _
    .Columns(Sub(columns)
                 columns.Bound(Function(model) model.AccountNumber).Title(CommericalPortal.BusinessData.Resources.BillingAndInvoices.PacAccountNumberLabel_ShortForm).Sortable(False)
                 columns.Bound(Function(model) model.BankNumber).Title(CommericalPortal.BusinessData.Resources.BillingAndInvoices.PacBankNumberLabel_ShortForm)
                 columns.Bound(Function(model) model.TransitNumber).Title(CommericalPortal.BusinessData.Resources.BillingAndInvoices.PacTransitNumberLabel_ShortForm)
                 columns.Bound(Function(model) model).Template(Function(obj) String.Format("<a href='{0}/{1}'>{2}</a>", Url.Content("~/PAC/Edit"), obj.ID, CommericalPortal.Web.My.Resources.GridText.EditLinkText)).Title("")
                 columns.Bound(Function(model) model).Template(Function(obj) String.Format("<a  href='{0}/{1}'>{2}</a>", Url.Content("~/PAC/ViewCheques"), obj.ID, CommericalPortal.Web.My.Resources.GridText.ViewChequesLinkText)).Title("")
         End Sub) _
    .Sortable(Function(sorting) sorting.SortMode(GridSortMode.SingleColumn).Enabled(True))
)`
4

1 回答 1

0

结构很好的问题,但是我很遗憾地说,在使用 Ajax 加载其内容的 TabStrip 内使用服务器绑定网格是不可能的。应该为Ajax 绑定配置网格。

于 2013-07-30T19:23:33.050 回答