Hallo,
I have a WHDG binded to a dataset. I need to export a single band level choosen by user, preserving grid formatting.
How can i do this?
Thanks
Hello maxanziuttiBasically you cant cancel the row exporting by using the following code
protected void WebExcelExporter1_RowExporting(object sender, Infragistics.Web.UI.GridControls.ExcelRowExportingEventArgs e) { ContainerGridRecord cgr = e.GridRow as ContainerGridRecord; if (cgr != null) { if (cgr.Level != 1) { e.Cancel = true; } } }
because the exporting is designed to be hierarchical and if you cancel the export of parent level all the tree of reccords which is hanging on the canceled reccord would not be exported. Currently your best option is to use the following code :
protected void Button1_Click(object sender, EventArgs e) { WebExcelExporter1.EnableStylesExport = true;
DataSet ds = WebHierarchicalDataGrid1.DataSource as DataSet; DataTable dt = ds.Tables[1]; WebDataGrid1.DataSource = dt; WebDataGrid1.DataBind(); WebExcelExporter1.Export(WebDataGrid1); //WebExcelExporter1.Export(WebHierarchicalDataGrid1); }Which is taking the whole dataset, getting the table which is supposed to be exported and exporting it via using a hidden webdatagrid like this:<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Visible="False" Width="400px" />
I haven't e.GridRow property in my version (i'm using last service release of 2011.1).
However, with this solution (having an hidden grid insted of original grid) I lose column formatting e data formatting made on InitalizeRow, right?