Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
WHDG: export single level
posted

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

Parents
No Data
Reply
  • 13438
    Suggested Answer
    posted

    Hello maxanziutti

    Basically 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" />

Children