0

我在Telerik 论坛上发布了这个,但我觉得我会在这里得到更快的回复,如果交叉发帖不受欢迎,我深表歉意。

我的 RadGrid 用于在每个网格的右下角显示页面和项目计数。我最近将 Telerik 从 v2011.3.1305 升级到 v2012.1.411。

我的一个网格的典型标记:

<telerik:RadGrid ID="AssetGrid" runat="server" AllowFilteringByColumn="True" AllowPaging="True"
    AllowSorting="True" GridLines="None" GroupingSettings-CaseSensitive="false" Skin="Web20"
    AutoGenerateColumns="False" OnPageIndexChanged="AssetGrid_PageIndexChanged" OnItemCreated="AssetGrid_ItemCreated"
    OnItemDataBound="AssetGrid_ItemDataBound"
    OnPreRender="AssetGrid_PreRender" OnSortCommand="AssetGrid_SortCommand" OnNeedDataSource="AssetGrid_NeedDataSource"
    EnableLinqExpressions="false">
    <ClientSettings EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowDblClick="RowAssetSelected" />
    </ClientSettings>
    <MasterTableView EditMode="InPlace" AllowFilteringByColumn="true" ShowFooter="false"
        EnableColumnsViewState="true" AutoGenerateColumns="false" CellSpacing="-1" DataKeyNames="AsId"
        Font-Size="90%" AllowCustomSorting="true" AllowCustomPaging="true" Width="100%">
        <PagerStyle Mode="NextPrevAndNumeric" Visible="true" AlwaysVisible="true" />
        <!-- RowIndicatorColumn, ExpandCollapseColumn, Columns, etc -->
    </MasterTableView>
</telerik:RadGrid>

我只在 NeedDataSource 的代码下面包含了,但如果其他任何人有帮助,请告诉我,我会发布它们:

protected void AssetGrid_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
    var collection = getAssets();
    AssetGrid.VirtualItemCount = collection.Count;
    AssetGrid.DataSource = collection.Skip(AssetGrid.PageSize * 
        AssetGrid.CurrentPageIndex).Take(AssetGrid.PageSize);
}

然而,网格正在显示寻呼机行,如下所示:

寻呼机显示

是否有我错过的设置来启用右下角的页面/项目计数,如几乎所有Telerik Pager 示例中所示?

提前致谢!

4

1 回答 1

0

尝试将此代码用于您的 PagerStyle:

    <PagerStyle PagerTextFormat="Page: {4} &amp;nbsp;Count: {5}" 
                Font-Names="Arial"
                ForeColor="#bebebe"
                Font-Size="12px"
                Mode="NextPrevAndNumeric"
                PageSizeLabelText="your lable for page size"
                AlwaysVisible="true"/>

你也可以试试这些属性:

 <telerik:RadGrid ... 
                    OnItemCreated="RadGrid_ItemCreated"                                        
                    PagerStyle-ShowPagerText="true">

您的 ItemCreated 事件的委托方法应如下所示:

protected void RadGrid_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridPagerItem)
    {
        var dropDown = (RadComboBox)e.Item.FindControl("PageSizeComboBox");
        var totalCount = ((GridPagerItem)e.Item).Paging.DataSourceCount;
        var sizes = new Dictionary<string, string>() {
            {"10", "10"},
            {"20", "20"},
            {"50", "50"}
        };
        if (totalCount > 100)
        {
            sizes.Add("100", "100");
        }
        if (totalCount > 200)
        {
            sizes.Add("200", "200");
        }
        sizes.Add("All", totalCount.ToString());

        dropDown.Items.Clear();
        foreach (var size in sizes)
        {
            var cboItem = new RadComboBoxItem() { Text = size.Key, Value = size.Value };
            cboItem.Attributes.Add("ownerTableViewId", e.Item.OwnerTableView.ClientID);
            dropDown.Items.Add(cboItem);
        }
        dropDown.FindItemByValue(e.Item.OwnerTableView.PageSize.ToString()).Selected = true;
    }
}
于 2016-03-23T09:39:37.720 回答