Hello,
The business requirements for my application require the use of modal windows due to the process involved in calculating commissions correctly. The problem I'm having is exporting to Excel when <base target="_self"> is included in the head tag of the page. Unfortunately, I've found that I need to include it in order for the grid to be grouped or ungrouped in the same window, the dialog window to be closed, or the grid to be updated in the same window (i.e., display a row in red when updated through a button).
In order to attempt to solve the problem, I've tried the various export modes along with a JavaScript function found when researching. So far, nothing is working. I've also changed to a modeless window and, although it works, I need to comply with the business requirements.
I would appreciate any help in getting grid results successfully exported to Excel from a modal window with <base target="_self"> in the head tag. I'm including the definition of the grid and the code for exporting below.
Thanks and have a great day!
Pat
<igtbl:UltraWebGrid ID="grdPreviewDetails" runat="server" Height="450px"
onungroupcolumn="grdPreviewDetails_UnGroupColumn"
oninitializerow="grdPreviewDetails_InitializeRow">
<Bands>
<igtbl:UltraGridBand BaseTableName="grdPreviewDetails" Key="key">
<AddNewRow Visible="NotSet" View="NotSet"></AddNewRow>
<Columns>
<igtbl:UltraGridColumn BaseColumnName="key" HeaderText="" Hidden="True" Key="key">
<Header Caption="">
</Header>
</igtbl:UltraGridColumn>
<igtbl:TemplatedColumn AllowGroupBy="No" AllowUpdate="Yes" BaseColumnName="Checked"
HeaderText="" Key="Checked" SortIndicator="Disabled" Type="CheckBox">
<Header Caption="Hold?">
<RowLayoutColumnInfo OriginX="1" />
<CellStyle HorizontalAlign="Center">
</CellStyle>
<Footer>
</Footer>
</igtbl:TemplatedColumn>
</Columns>
</igtbl:UltraGridBand>
</Bands>
AllowSortingDefault="OnClient" AllowDeleteDefault="Yes"
TableLayout="Fixed" ViewType="OutlookGroupBy" RowSelectorsDefault="No"
StationaryMargins="Header" BorderCollapseDefault="Separate"
NoDataMessage="There are no payments to preview" IndentationDefault="0"
GroupByRowDescriptionMaskDefault="[caption] : [value] ([count]; [sum:AmountPaid])">
<Style BackColor="ActiveBorder" BorderColor="Window"></Style>
<FrameStyle BackColor="Window" BorderColor="InactiveCaption" BorderWidth="1px"
Height="450px" Width="797px"></FrameStyle>
InitializeLayoutHandler="grdPreviewDetails_InitializeLayoutHandler" />
<Style BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid">
<BorderDetails ColorLeft="White" ColorTop="White" WidthLeft="1px" WidthTop="1px"></BorderDetails>
</Pager>
<FooterStyleDefault BackColor="LightGray" BorderWidth="1px" BorderStyle="Solid">
</FooterStyleDefault>
<RowStyleDefault BackColor="Window" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid">
<BorderDetails ColorLeft="Window" ColorTop="Window"></BorderDetails>
<GroupByRowStyleDefault BackColor="Control" BorderColor="Window"></GroupByRowStyleDefault>
<Style BackColor="Window" BorderColor="InactiveCaption" BorderWidth="1px" BorderStyle="Solid">
</AddNewBox>
<FilterDropDownStyle CustomRules="overflow:auto;" BackColor="White" BorderColor="Silver" BorderWidth="1px" BorderStyle="Solid" Font-Names="Verdana,Arial,Helvetica,sans-serif" Font-Size="11px" Height="300px" Width="200px">
</FilterDropDownStyle>
</FilterOptionsDefault>
</DisplayLayout>
</igtbl:UltraWebGrid>
<div id="divExport" style="z-index: 107; left: 12px; width: 479px; position: absolute;
top: 566px; height: 53px">
EnableViewState="false" oninitializecolumn="UltraWebGridExcelExporter1_InitializeColumn" >
</cc1:UltraWebGridExcelExporter>
</div>
{
string strMonth = System.DateTime.Today.Month.ToString();
//Add leading zero if month is single digit
}
//Add leading zero if day is single digit
grdPreviewDetails.Columns.FromKey("AmountPaid").HeaderText = "Payment";
grdPreviewDetails.Columns.FromKey("AmountPaid").Format = "C"; //To ensure the export retains the currency format, set the value to "C" here; it is checked/set in the InitializeColumn function.
UltraWebGridExcelExporter1.DownloadName = strFileName;
UltraWebGridExcelExporter1.Export(grdPreviewDetails); //,strFileName
pgrimes629 said: I would appreciate any help in getting grid results successfully exported to Excel from a modal window with <base target="_self"> in the head tag.
I seem to recall some browsers faced challenges, at least in the past, when opening an Excel file from within a window created via showModal( ). If you put an ordinary hyperlink on this page to a temporary .xls (not one produced by the exporter, just save an empty workbook from Excel) that is being hosted at some path on your Web server, and you click on this hyperlink - does it download/open successfully within the modal window?
If so, then at least one approach you should be able to use is ExportMode.Custom and then arrange for the file stream so created and stored temporarily on the server to be downloaded by the modal window. If the hyperlink test doesn't work then you'll know the challenge isn't with the WebGridExcelExporter, but the modal window opening of an Excel file limitation.
The above assumes you're using showModal( ) or something similar to create this window and perhaps that isn't the case. The WebDialogWindow control supports a modal display mode that prevents interaction by the user with the browser contents in the background, have you tried exporting the grid using a WebDialogWindow?
Thank you for the suggestions. I have tried the exportmode.custom method without much success. Do you have an easy-to-follow/understand sample? One thing I need to make sure of is to allow the user to save the worksheet to a place of their choice.
I'll try the hyperlink suggestion and see where that takes me.