sharepoint 2010 visual web part and radgrid export

7 posts, 0 answers
  1. Myat
    Myat avatar
    1 posts
    Member since:
    Oct 2011

    Posted 20 Oct 2011 Link to this post

    export to excel,pdf,csv are not working.  below is the code sample.

     

     

    <asp:UpdatePanel runat="server"><ContentTemplate>
    <telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="true" Skin="Outlook"
        AutoGenerateColumns="False" PageSize="12" AllowSorting="True" AllowMultiRowSelection="False"
        AllowPaging="True" OnNeedDataSource="RadGrid1_NeedDataSource" 
        OnItemCommand="RadGrid1_ItemCommand" AllowFilteringByColumn="True">
        <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
        <ExportSettings IgnorePaging="true" OpenInNewWindow="true" ExportOnlyData="true"/>
        <ClientSettings>
            <Scrolling AllowScroll="true" UseStaticHeaders="false"/>
            </ClientSettings>
      
        <MasterTableView Width="100%" DataKeyNames="intID" AllowMultiColumnSorting="True" CommandItemDisplay="Top"
            CommandItemSettings-ShowExportToExcelButton="true" CommandItemSettings-ShowAddNewRecordButton="false" UseAllDataFields="true">
        <Columns>
            <telerik:GridEditCommandColumn></telerik:GridEditCommandColumn>
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" />
            <telerik:GridBoundColumn SortExpression="strSiteID" HeaderText="Location" HeaderButtonType="LinkButton"
                DataField="strSiteID">
            </telerik:GridBoundColumn>
            <telerik:GridDateTimeColumn  SortExpression="dtInvoiceDate" HeaderText="Invoice Date" HeaderButtonType="LinkButton"
                DataField="dtInvoiceDate" DataFormatString="{0:d}" PickerType="DatePicker" FilterControlWidth="100px" >
            </telerik:GridDateTimeColumn>
            <telerik:GridBoundColumn SortExpression="strInvoiceNo" HeaderText="Invoice" HeaderButtonType="LinkButton"
                DataField="strInvoiceNo">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="strItemNo" HeaderText="Part #" HeaderButtonType="LinkButton"
                DataField="strItemNo">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="intItemCount" HeaderText="QTY" HeaderButtonType="LinkButton"
                DataField="intItemCount">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="strCondition" HeaderText="Condition" HeaderButtonType="LinkButton"
                DataField="strCondition">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="strStatus" HeaderText="Status" HeaderButtonType="LinkButton"
                DataField="strStatus">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="strETA" HeaderText="ETA" HeaderButtonType="LinkButton"
                DataField="strETA">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn SortExpression="strBoxID" HeaderText="Box ID" HeaderButtonType="LinkButton"
                DataField="strBoxID">
            </telerik:GridBoundColumn>
        </Columns>
        </MasterTableView>
    </telerik:RadGrid>
    </ContentTemplate></asp:UpdatePanel>

    disabling ajaxifying didn't help.

     
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 25 Oct 2011 Link to this post

    Hi Myat,

    You need the following code in the OnInit event of your web part class:
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        Page.ClientScript.RegisterStartupScript(typeof(Web_Part1), this.ID, "_spOriginalFormAction = document.forms[0].action;_spSuppressFormOnSubmitWrapper=true;", true);
        if (this.Page.Form != null)
        {
            string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"];
            if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();")
            {
                this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();";
            }
        }
    }


    Hope it helps.

    Best wishes, Tsvetoslav
    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

  3. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 23 Aug 2012 Link to this post

    Thanks Tsvetoslav.I have two seperate RadGrid controls in UserControl and these two control is used in radTabstrip in visual webpart.everything is ajaxify and working well with your help.Now i want to add Export functionality.
    I know i need to first cancel Ajax request but how can i add client events as i am adding Ajaxmanager programaticlly.i got your help from this thread....

    Please advise

    Thanks
    ROnak 
     
  4. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 28 Aug 2012 Link to this post

    Hello Ronak,

    You could get reference to the main RadAjaxManager control and add handlers for the needed client events like this:

    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadAjaxManager manager = RadAjaxManager.GetCurrent(Page);
        manager.ClientEvents.OnRequestStart = "onRequestStart";
        manager.ClientEvents.OnResponseEnd = "onResponseEnd";
        manager.AjaxRequest += new RadAjaxControl.AjaxRequestDelegate(manager_AjaxRequest);
    }
    protected void manager_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
        //handle the manager AjaxRequest event here
    }

    I hope this helps.

    Regards,
    Maria Ilieva
    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.
  5. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 28 Aug 2012 Link to this post

    Thanks Maria i will try and share knowledge here

    Ronak
  6. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 28 Aug 2012 Link to this post

    Thanks Maria it worked and i can export to PDF,word and excel but everytime i need to refersh page after one export meaning lets say first i exported to PDF now if i want to export to word or excel i have to refersh page.

    Thanks 
    ROnak
  7. Ronak
    Ronak avatar
    108 posts
    Member since:
    Sep 2010

    Posted 28 Aug 2012 Link to this post

    Thanks Maria it is fixed code provided by Tsvetoslav in this thread.

    Ronak
Back to Top