RadGridView + RadContextMenu + Export to Excel

4 posts, 0 answers
  1. Meehir
    Meehir avatar
    14 posts
    Member since:
    Oct 2010

    Posted 17 May 2011 Link to this post


    We are using Telerik RadGridView controls for my Silverlight application and we need to have export to excel functionality by implementing context menu.  So, when user right clicks the grid, context menu should appear and on clicking on one menu item, it should export the grid data to excel.  We are following MVVM models.

    Below is my code snippets:
    <Telerik:RadGridView x:Name="Grid1" ...>
        <Telerik:ContextMenu Name="Menu1">
          <Telerik:MenuItem Header = "Export to Excel" Command="{Binding ExportCommand}" CommandParameter="{Binding ElementName=Grid1}">

    In ViewModel, I have created the ICommand variable "ExportCommand" as below

    public ICommand ExportCommand


          _exportCommand = new DelegateCommand<object>(

                    commandParameter => {
                             var grid = commandParameter as RadGridView;
                              .... put all the code to show dialog for exporting to excel which is working in other forms perfectly
                              ..... but with CommandButton


         return _exportCommand;


    I am not getting the grid to export.  On executing below line, the grid variable becomes null.  So no data to export to excel.
    var grid = commandParameter as RadGridView;

    Kindly help.

    Meehir Jha

  2. Vlad
    Vlad avatar
    11100 posts

    Posted 18 May 2011 Link to this post


     ElementName binding will not work in this case. I've attached example project to illustrate you how to achieve your goal.

    All the best,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Ricardo
    Ricardo avatar
    8 posts
    Member since:
    Jun 2013

    Posted 24 Jun 2014 Link to this post

    Hola, quiero exportar mi RadGridview desde un comando Command="{Binding ComandoExportar}" CommandParameter="{Binding ElementName=gdvILI}" pero al exportarlo sólo me exporta la página actual del Gridview y yo quiero exportar todo el Gridview sin importar el paginado.
  4. Dimitrina
    Dimitrina avatar
    3769 posts

    Posted 25 Jun 2014 Link to this post


    You can check the "Export FAQ" article in our online documentation on how to achieve your goal.
    Basically, you need to:
    • Save the PageSize and the PageIndex of RadDataPager

    • Set the PageSize of RadDataPager to 0

    • Export the data (you can use the (IEnumerable) dataPager.PagedSource as GridViewExportOptions.Items)

    • Set the PageSize and the PageIndex back

    You can also export data with RadSpreadProcessing. The model is completely independent from UI. You can check our new example Export with RadSpreadProcessing on how to do so.

    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
Back to Top