在radGrid Telerik Asp.Net中打印数据后的AllowPaging

时间:2014-03-31 14:42:02

标签: c# javascript asp.net telerik radgrid

我一直在寻找一种在radGrid Telerik中打印数据的方法,我找到了Here的方法如下:

代码背后

radGrid.CurrentPageIndex                      = 0;
radGrid.ClientSettings.Scrolling.AllowScroll  = false;
radGrid.AllowPaging                           = false;
radGrid.AllowFilteringByColumn                = false;
radGrid.MasterTableView.GroupsDefaultExpanded = true;
radGrid.Rebind();

foreach (GridItem item in radGrid.MasterTableView.GetItems(new GridItemType[] { GridItemType.Pager, GridItemType.FilteringItem }))
            item.Display = false;

RadAjaxPanel1.ResponseScripts.Add("PrintRadGrid('" + radGrid.ClientID + "')");

JavaScript的:

function PrintRadGrid() {
var radGridE = $find('<%= radGrid.ClientID %>');
var previewWindow = window.open('about:blank', '', '', false);
var styleSheet = '<%= Telerik.Web.SkinRegistrar.GetWebResourceUrl(this.Page, radGrid.GetType(), String.Format("Telerik.Web.UI.Skins.{0}.Grid.{0}.css", radGrid.Skin)) %>';
var baseStyleSheet = '<%= Telerik.Web.SkinRegistrar.GetWebResourceUrl(this.Page, radGrid.GetType(), "Telerik.Web.UI.Skins.Grid.css") %>';
var htmlContent = "<html><head><link href = '" + styleSheet + "' rel='stylesheet' type='text/css'></link>";

htmlContent += "<link href = '" + baseStyleSheet + "' rel='stylesheet' type='text/css'></link></head>";
htmlContent = htmlContent + "<body>" + getOuterHTML(radGridE.get_element()) + "</body></html>";
previewWindow.document.open();
previewWindow.document.write(htmlContent);
previewWindow.document.close();
previewWindow.print();

if (!$telerik.isChrome) {
            previewWindow.close();
 }
}

代码运行良好但它禁用了分页以打印所有页面。现在我想要一种在不刷新页面的情况下再次允许分页的方法。

如何在不刷新页面的情况下再次将AllowPaging设置为true?

1 个答案:

答案 0 :(得分:2)

打印后启动回发(最好是AJAX)并在代码隐藏中启用分页。了解如何在此处发起ajaxRequest:http://www.telerik.com/help/aspnet-ajax/ajax-client-side-api.html