This is a migrated thread and some comments may be shown as answers.

RadGrid Export with DNN 6.0

4 Answers 109 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 23 Sep 2011, 10:38 PM
Hi, I'm testing an existing site on DNN 6.0 and I've got a problem with the export feature of radgrid. Works fine in DNN 5.6 but when I try it on DNN 6.0 the screen goes white during post back and never returns to the page. The file dialog opens up to save, open or cancel, but after you do anything the page with the radgrid stays white. If I refresh the page it works ok. 

I'm using an external button to do the export and to get it work under DNN 5.6 I had to disable postback (see code below). If I remove that code the pdf output and the excel output show up inside the radgrid, but you can't save it.

Not sure how to tackle this?

Thanks, all help is appreciated.



Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(initializeRequestHandler);
 
function initializeRequestHandler(sender, args) {
    if (args.get_postBackElement().id.indexOf("ExportPDFButton") != -1) {
        args.set_cancel(true);
        sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
        sender._form["__EVENTARGUMENT"].value = "";
        sender._form.submit();
        return;
    }
 
    if (args.get_postBackElement().id.indexOf("ExportExcelButton") != -1) {
        args.set_cancel(true);
        sender._form["__EVENTTARGET"].value = args.get_postBackElement().id.replace(/\_/g, "$");
        sender._form["__EVENTARGUMENT"].value = "";
        sender._form.submit();
        return;
    }

4 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 28 Sep 2011, 11:32 AM
Hello Tim,

Can you try setting OpenInNewWidnow to true in the grid export settings and see if it makes any difference? 
Additionally, if the grid is ajaxified with RadAjax, you can try disabling ajax as described here

Kind regards,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Tim
Top achievements
Rank 1
answered on 28 Sep 2011, 08:08 PM

Thanks for the reply. OpenInNewWindow is set to true. See radgrid code below. I'm not using RadAjax because DNN already adds a scriptmanager. If I turn off the partial rendering option on the DNN module it will work, but that seems to disable AJAX for the entire module/page.

    <telerik:RadGrid runat="server" ID="ManagerRadGrid" Skin="Outlook" CssClass="msGrid"
    AllowMultiRowSelection="true" DataSourceID="LinqDataManageCases" AllowFilteringByColumn="false"
    AllowPaging="True" PageSize="100" PagerStyle-AlwaysVisible="true" OnItemCreated="ManagerRadGrid_ItemCreated"
    AllowSorting="True" AutoGenerateColumns="False" Width="99%" OnItemCommand="CaseManagerRadGrid_ItemCommand">
    <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom"></PagerStyle>
    <ClientSettings> <Selecting UseClientSelectColumnOnly="true" AllowRowSelect="true" /> </ClientSettings>
    <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true"
        HideStructureColumns="true" FileName="MidShore_Cases">
        <Pdf Title="MidShore Pro Bono - Cases" PageHeight="210mm" PageWidth="400mm" PageTopMargin="15mm"
            PageBottomMargin="15mm" PageLeftMargin="12mm" PageRightMargin="12mm" Author="MidShore Pro Bono" />
          
    </ExportSettings>
    <MasterTableView CommandItemDisplay="None" DataKeyNames="caseId" ClientDataKeyNames="caseId" HeaderStyle-HorizontalAlign="Center">
        <Columns
            <telerik:GridClientSelectColumn UniqueName="SelectCaseCheckbox" HeaderStyle-Width="10px" HeaderStyle-CssClass="msGridNarrowHeader" ItemStyle-HorizontalAlign="Center"  />
  
            <telerik:GridButtonColumn ButtonType="LinkButton" UniqueName="EditCaseButton" HeaderStyle-Width="30px" HeaderStyle-CssClass="msGridNarrowHeader" ItemStyle-HorizontalAlign="Center"
                CommandName="EditCaseCommand" Text="Edit" />
  
            <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="../Images/delete.gif"
                UniqueName="DeleteCaseButton" HeaderStyle-Width="20px" ItemStyle-HorizontalAlign="Center"
                CommandName="DeleteCaseCommand" ConfirmText="Are you sure you want to delete this case?" />
  
            <telerik:GridBoundColumn HeaderText="InTake" DataField="intakeDate" UniqueName="intakeDate"
                SortExpression="intakeDate" HeaderStyle-Width="60px" AllowFiltering="false" DataFormatString="{0:MM/dd/yyyy}"
                ItemStyle-HorizontalAlign="Center"  />
  
            <telerik:GridBoundColumn HeaderText="Placed" DataField="datePlaced" UniqueName="datePlaced"
                SortExpression="datePlaced" HeaderStyle-Width="60px" AllowFiltering="false" DataFormatString="{0:MM/dd/yyyy}"
                ItemStyle-HorizontalAlign="Center" />
  
            <telerik:GridBoundColumn HeaderText="Closed" DataField="closedDate" UniqueName="closedDate"
                SortExpression="closedDate" HeaderStyle-Width="60px" AllowFiltering="false" DataFormatString="{0:MM/dd/yyyy}"
                ItemStyle-HorizontalAlign="Center" />
  
            <telerik:GridBoundColumn HeaderText="Hearing" DataField="hearingDateTime" UniqueName="HearingDate" HeaderStyle-HorizontalAlign="Center"
                SortExpression="hearingDateTime" HeaderStyle-Width="130px" AllowFiltering="false" DataFormatString="{0:MM/dd/yyyy - h:mm tt}"
                ItemStyle-HorizontalAlign="Left" />
  
            <telerik:GridBoundColumn DataField="attendClinic" UniqueName="attendClinic" HeaderText="Clinic"
                HeaderStyle-CssClass="msGridNarrowHeader" HeaderStyle-Width="25px" AllowFiltering="false"
                ItemStyle-HorizontalAlign="Center" />
  
            <telerik:GridBoundColumn HeaderText="Client" DataField="clientName" AllowFiltering="false" UniqueName="Client"
                SortExpression="clientName" HeaderStyle-Width="150px"/>
  
            <telerik:GridBoundColumn HeaderText="Case Type" HeaderStyle-Width="225px" DataField="caseType" UniqueName="caseType"
                SortExpression="caseType" AllowFiltering="false" />
  
            <telerik:GridBoundColumn HeaderText="Case Status" DataField="caseStatus" AllowFiltering="false" UniqueName="CaseStatus"
                SortExpression="caseStatus" HeaderStyle-Width="120px"/>
  
            <telerik:GridBoundColumn HeaderText="Doc Status" DataField="docStatus" AllowFiltering="false" UniqueName="DocStatus"
                SortExpression="docStatus" HeaderStyle-Width="85px"/>
  
            <telerik:GridBoundColumn DataField="judicare" UniqueName="judicare" HeaderText="Judi" HeaderStyle-CssClass="msGridNarrowHeader"
                HeaderStyle-Width="25px" AllowFiltering="false" ItemStyle-HorizontalAlign="Center" />
  
            <telerik:GridBoundColumn HeaderText="Attorney" DataField="attorneyName" AllowFiltering="false" UniqueName="AttorneyName"
                SortExpression="attorneyName" HeaderStyle-Width="120px"/>
            <telerik:GridBoundColumn HeaderText="Marital Status" DataField="maritalStatus" AllowFiltering="false" Visible="false"
                UniqueName="MaritalStatus" SortExpression="maritalStatus" HeaderStyle-Width="70px" />
            <telerik:GridBoundColumn HeaderText="Gender" DataField="gender" AllowFiltering="false"
                Visible="false" UniqueName="Gender" SortExpression="gender" HeaderStyle-Width="50px" />
            <telerik:GridBoundColumn HeaderText="Age" DataField="age" AllowFiltering="false"
                Visible="false" UniqueName="Age" SortExpression="age" HeaderStyle-Width="40px" />
            <telerik:GridBoundColumn HeaderText="Ethnicity" DataField="ethnicity" AllowFiltering="false"
                Visible="false" UniqueName="Ethnicity" SortExpression="ethnicity" HeaderStyle-Width="150px" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Code Behind:
  

protected void ExportPDFButton_Click(object sender, EventArgs e)
{
    isExport = true;
    ManagerRadGrid.MasterTableView.GetColumn("SelectCaseCheckbox").Visible = false;
    ManagerRadGrid.MasterTableView.GetColumn("EditCaseButton").Visible = false;
    ManagerRadGrid.MasterTableView.ExportToPdf();
    messageLabel.Text = messageLabel.Text + " Export to PDF";
}
protected void ExportExcelButton_Click(object sender, EventArgs e)
{
    isExport = true;
    ManagerRadGrid.MasterTableView.GetColumn("SelectCaseCheckbox").Visible = false;
    ManagerRadGrid.MasterTableView.GetColumn("EditCaseButton").Visible = false;
    ManagerRadGrid.MasterTableView.GetColumn("MaritalStatus").Visible = true;
    ManagerRadGrid.MasterTableView.GetColumn("Gender").Visible = true;
    ManagerRadGrid.MasterTableView.GetColumn("Age").Visible = true;
    ManagerRadGrid.MasterTableView.GetColumn("Ethnicity").Visible = true;
    ManagerRadGrid.MasterTableView.ExportToExcel();
    messageLabel.Text = messageLabel.Text + " Export to Excel";
}
protected void ManagerRadGrid_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem && isExport)
    {
        foreach (TableCell cell in e.Item.Cells)
        {
            cell.Style["border"] = "thin solid #888888";
            //cell.Style["border-right"] = "thin solid #888888";
            //               cell.Style["border-width"] = "thin"; 
            //               cell.Style["border-color"] = "#888888"; 
        }
        //  e.Item.Style["border"] = "1px solid #888888";
    }
}
0
Iana Tsolova
Telerik team
answered on 29 Sep 2011, 01:20 AM
Hello Tim,

When partial rendering is enabled for the module, this ajaxifies it by wrapping it in ASP:UpdatePanel. However for the RadGrid export to work, the export button needs to perform regular postback. So there are two ways to proceed:
    - To leave the partial rendering enabled and add the Export button to the ScriptManager postback triggers.
    - Disable the partial rendering for the module and use RadAjax to ajaxify it. Then disable ajax for the export button as previously suggested.

All the best,
Iana Tsolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Tim
Top achievements
Rank 1
answered on 24 Oct 2011, 05:57 PM
 
Tags
Grid
Asked by
Tim
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Tim
Top achievements
Rank 1
Share this question
or