[转]WebGrid导出常见问题汇总记录
最近一个项目用到ISNet.WebGrid,其中的导出功能不清楚,上网搜的,以备用:
"Printer does not support Letter papersize. Please use PaperKind. Custom in your PageSettings or specify a papersize supported by the current printer"
错误。
解决
private void WebGrid1_PrepareExportExecute (object sender, ISNet.WebUI.WebGrid.PrepareExportExecuteEventArgs e)
{
e.ReportObject.Document.Printer.PrinterName = "";
}
2.导出的WebGrid某些列是WebCombo下拉框,导出的是ID
解决
private void WebGrid1_Export(object sender, ISNet.WebUI.WebGrid.ExportEventArgs e) { e.ReportInfo.EnableValueList = true; }
3.导出递归的WebGrid情况
解决
protected void WebGrid1_Export(object sender, ISNet.WebUI.WebGrid.ExportEventArgs e)
{
e.ReportInfo.ExportAllSelfReferencingRows = true;
}
4.VirtualLoadMode=LargeData时候导出所有数据
解决
private void Button1_Click(object sender, System.EventArgs e) { // in order to export all the data // the VirtualLoadMode should be modified back to Default // temporarily WebGrid1.LayoutSettings.VirtualLoadMode = ISNet.WebUI.WebGrid.VirtualLoadMode.Default; // rebind the data source WebGrid1.RebindDataSource(); // invoke the Export Grid feature WebGrid1.ExportGrid(SetDynInfo()); // the VirtualLoadMode is configured back // to LargeData option WebGrid1.LayoutSettings.VirtualLoadMode = ISNet.WebUI.WebGrid.VirtualLoadMode.LargeData; }
5.客户端导出功能调用
解决
To invoke export programmatically, use exportGrid() method of the grid object. The exportGrid method contains following parameters:
tblName
The name of the table you want to export.
exportType
The type of the generated output. Built-in types includes "html", "pdf", "xml", "excel", "tiff", "rtf" and "text".
pageOrientation
The orientation of the result page. This is not applicable to Excel exportType as it is exported as raw data. Valid input is "Landscape" or "Portrait".
parentRow*
The parent row reference of the child table to export. This parameter is only needed for child table exporting.
The following codes show how to export Customers table to html programmatically on button click.
function exportButton_click()
{
var grid = wgGetGridById("WebGrid1");
grid.exportGrid("Customers", "html", "Landscape");
}
浙公网安备 33010602011771号