我在Telerik Forums发布了这个帖子,但我有一种感觉,我会在这里得到更快的回复,如果交叉帖子不赞成就道歉。
我的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 Examples所示?
提前致谢!
答案 0 :(得分:0)
尝试将此代码用于PagerStyle:
<PagerStyle PagerTextFormat="Page: {4} &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;
}
}