Código em C#:
private void ClickToolbar(short value)
{
this.ExportSettings.HideStructureColumns = true;
this.ExportSettings.FileName = string.Concat(this.ExportSettings.Pdf.PageTitle, " - Exportação");
this.MasterTableView.HierarchyDefaultExpanded = false;
this.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerOnDemand;
if (this.MasterTableView.HasDetailTables)
{
for (int i = 0; i < this.MasterTableView.DetailTables.Count; i++)
{
this.MasterTableView.DetailTables[i].HierarchyDefaultExpanded = false;
this.MasterTableView.DetailTables[i].HierarchyLoadMode = GridChildLoadMode.ServerOnDemand;
}
}
GridTableView backupMasterTableView = this.MasterTableView.Clone();
switch (value)
{
case 0:
GridSettingsPersister savePersister = new GridSettingsPersister(this);
object[] parameters = new object[] { this.IdGridConfiguracao, savePersister.SaveSettings() };
this.Page.GetType().GetMethod("SalvarConfiguracaoGrid").Invoke(this.Page, parameters);
if (RebindOnClickSaveToolbar)
this.Rebind();
break;
case 2:
exporting = true;
PrepareToPrintGrid();
this.MasterTableView.ExportToPdf();
break;
case 4:
#region Formato do Excel
this.ExportSettings.Excel.Format = Telerik.Web.UI.GridExcelExportFormat.Biff;
#endregion
PrepareToPrintGrid();
exporting = true;
this.MasterTableView.ExportToExcel();
this.MasterTableView.Rebind();
break;
}
if (exporting)
{
this.MasterTableView.HeaderStyle.Wrap = backupMasterTableView.HeaderStyle.Wrap;
this.MasterTableView.ItemStyle.Wrap = backupMasterTableView.ItemStyle.Wrap;
this.MasterTableView.Font.Size = backupMasterTableView.Font.Size;
this.MasterTableView.Font.Name = backupMasterTableView.Font.Name;
this.MasterTableView.Style["vertical-align"] = backupMasterTableView.Style["vertical-align"];
this.MasterTableView.Style["text-align"] = backupMasterTableView.Style["text-align"];
this.MasterTableView.UseAllDataFields = backupMasterTableView.UseAllDataFields;
this.MasterTableView.HierarchyDefaultExpanded = backupMasterTableView.HierarchyDefaultExpanded;
this.MasterTableView.HierarchyLoadMode = backupMasterTableView.HierarchyLoadMode;
this.MasterTableView.PageSize = backupMasterTableView.PageSize;
this.MasterTableView.AllowPaging = backupMasterTableView.AllowPaging;
}
}
protected void PrepareToPrintGrid()
{
#region Seleciona o tamanho do papel
// Change to legal paper for high column counts
if (this.MasterTableView.Columns.Count > 8)
{
this.ExportSettings.Pdf.PaperSize = GridPaperSize.Legal;
}
// Change to portrait if many columns
if (this.MasterTableView.Columns.Count > 3)
{
Unit swapUnit = this.ExportSettings.Pdf.PageWidth;
this.ExportSettings.Pdf.PageWidth = this.ExportSettings.Pdf.PageHeight;
this.ExportSettings.Pdf.PageHeight = swapUnit;
this.ExportSettings.IgnorePaging = true;
this.ExportSettings.OpenInNewWindow = true;
}
#endregion
#region Estilos
this.ExportSettings.Pdf.DefaultFontFamily = "Segoe UI";
this.MasterTableView.HeaderStyle.Wrap = true;
this.MasterTableView.ItemStyle.Wrap = true;
this.MasterTableView.Font.Size = 8;
this.MasterTableView.Font.Name = "Segoe UI";
this.MasterTableView.Style["vertical-align"] = "middle";
this.MasterTableView.Style["text-align"] = "left";
#endregion
//this.ExportSettings.IgnorePaging = true;
this.ExportSettings.IgnorePaging = true;
this.ExportSettings.OpenInNewWindow = true;
this.MasterTableView.UseAllDataFields = true;
#region Expande Detailstable
this.MasterTableView.HierarchyDefaultExpanded = true;
this.MasterTableView.HierarchyLoadMode = GridChildLoadMode.Client;
if (this.MasterTableView.HasDetailTables)
{
for (int i = 0; i < this.MasterTableView.DetailTables.Count; i++)
{
this.MasterTableView.DetailTables[i].HierarchyLoadMode = GridChildLoadMode.Client;
this.MasterTableView.DetailTables[i].HierarchyDefaultExpanded = true;
}
this.MasterTableView.HierarchyDefaultExpanded = true;
}
#endregion
}
Código em javascript:
$(document).on('click', '.btn_toolbar_excel', function (e) {
setTimeout(function () { preventTableBreakPager() }, 5000);
})
function preventTableBreakPager()
{
var gridVeiculosList = $find(gridVeiculos).get_masterTableView();
gridVeiculosList.rebind();
}