Telerik
Skip Navigation LinksHome / Community / Forums / ASP.NET > Grid > AddNewRecord and Refresh buttons problem while exporting

AddNewRecord and Refresh buttons problem while exporting

Feed from this thread
  • Rycho Master avatar

    Posted on Apr 10, 2007 (permalink)

    My grid settings are:

                        Grid.ExportSettings.ExportOnlyData = True
                        Grid.ExportSettings.IgnorePaging = True
                        Grid.ExportSettings.OpenInNewWindow = True
                        Grid.ExportSettings.FileName = Grid.Title
                        Grid.MasterTableView.ExportToExcel()

    AddNewRecord and Refresh buttons are situated at the bottom of grid. Despite of setting "ExportOnlyData = True", after exporting I still get AddNewRecord and Refresh links inside my Excel 2003 sheet located at the end of course. Is it a bug or something?


    Reply

  • Telerik Admin admin's avatar

    Posted on Apr 10, 2007 (permalink)

    Hi Rycho,

    Due to the slightly modified grid rendering the command item content will be part of the resulting export document. To avoid this unwanted effect, you can hide that item prior to the export action, namely:

            GridItem[] commandItems = RadGrid1.MasterTableView.GetItems(GridItemType.CommandItem);  
            foreach (GridItem item in commandItems)  
            {  
                item.Visible = false;  
            }  
            RadGrid1.MasterTableView.ExportToExcel(); 

    Best regards,
    Stephen
    the telerik team

    Instantly find answers to your questions at the new telerik Support Center

    Reply

  • Rycho Master avatar

    Posted on Apr 10, 2007 (permalink)

    Hi,

        I think I found a better way:

    Grid.MasterTableView.CommandItemDisplay = Telerik.WebControls.GridCommandItemDisplay.None 
    Grid.ShowStatusBar = False 
    Grid.MasterTableView.Columns.FindByUniqueName("edit").Visible = False 
    Grid.MasterTableView.Columns.FindByUniqueName("delete").Visible = False 
    Grid.MasterTableView.ExportToExcel() 

    Regards,
        Rycho

    Reply

  • Rycho Master avatar

    Posted on Apr 15, 2007 (permalink)

    Hi,

    I still cannot see gridlines inside my Excel file. I tried Grid.ExportSettings.ExportOnlyData = True andGrid.ExportSettings.ExportOnlyData = False as well. No results

    Reply

  • Rycho Master avatar

    Posted on Apr 15, 2007 (permalink)

    I checked it deeper and found the solution: I forgot to use GridLines="Both". Please ignore my previous post

    Bye

    Reply

  • Rycho Master avatar

    Posted on May 14, 2007 (permalink)

    Hi,

    I spotted another problem: after successful export to excel my grid stopped handling SelectedIndexChanged server event. But when I sort, refresh or do any other action after export (action which makes roundtrip to server) -  grid starts to work correctly.

    My grid's settings are:
    enableAJAX='False'
    EnablePostBackOnRowClick="True"
    AllowRowSelect="True"

    I use AjaxManager.


    Reply

  • Telerik Admin admin's avatar

    Posted on May 16, 2007 (permalink)

    Hi Rycho,

    This one seems like a bug in ajax code.  Disabling AJAX in order to export breaks EnablePostBackOnRowClick setting in RadGrid. Our developers have been notified and they will consider it for a fix. One possible workaround would be to exclude the button that triggers the export from AJAX manager's settings. If the button is placed inside a RadGrid item you may consider hooking on the client click event and perform a postback as shown in this help topic.

    Your Telerik points have been updated.

    Best wishes,
    Ves
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center

    Reply

Back to Top

Skip Navigation LinksHome / Community / Forums / ASP.NET > Grid > AddNewRecord and Refresh buttons problem while exporting

Powered by Sitefinity ASP.NET CMS

Contact Us | Site Feedback | Terms of Use | Privacy Policy
Copyright © 2002-2010 Telerik. All rights reserved.