Intersoft ClientUI Documentation
ExportItems Property
See Also  Send Feedback
Intersoft.Client.UI.Data Namespace > UXGridView Class : ExportItems Property






Gets or sets the items to be exported.

Syntax

Visual Basic (Declaration) 
<CategoryAttribute("Data Exporting")>
Public Property ExportItems As IEnumerable
Visual Basic (Usage)Copy Code
Dim instance As UXGridView
Dim value As IEnumerable
 
instance.ExportItems = value
 
value = instance.ExportItems
C# 
[CategoryAttribute("Data Exporting")]
public IEnumerable ExportItems {get; set;}
Delphi 
public read-write property ExportItems: IEnumerable; 
JScript 
CategoryAttribute("Data Exporting")
public function get,set ExportItems : IEnumerable
Managed Extensions for C++ 
[CategoryAttribute("Data Exporting")]
public: __property IEnumerable* get_ExportItems();
public: __property void set_ExportItems( 
   IEnumerable* value
);
C++/CLI 
[CategoryAttribute("Data Exporting")]
public:
property IEnumerable^ ExportItems {
   IEnumerable^ get();
   void set (    IEnumerable^ value);
}

Example

The following code shows you how to bind ExportItems and ExportCommand in the ViewModel and supply the data to export.

View Model Copy Code
using System.Collections;
using System.ServiceModel.DomainServices.Client;
using System.Windows;
using HowToSamples.Web;
using Intersoft.Client.Data.ComponentModel;
using Intersoft.Client.Data.Provider.Ria;
using Intersoft.Client.Framework.Input;

namespace HowToSamples.ViewModels
{
    public class ExportingViewModel: ViewModelBase
    {
        public ExportingViewModel()
        {
            this.Manager = new NorthwindDomainContext();
            this.CanUserExport = true;
            this.QueryDescriptor = new QueryDescriptor();
            this.ExportCommand = new DelegateCommand(ExecuteExportCommand);
        }

        private bool _canUserExport;
        private IEnumerable _exportItems;
        private IEnumerable _products;
        private QueryDescriptor _queryDescriptor;
       
        private NorthwindDomainContext Manager { get; set; }

        public bool CanUserExport
        {
            get { return this._canUserExport; }
            set
            {
                if (this._canUserExport != value)
                {
                    this._canUserExport = value;
                    this.OnPropertyChanged("CanUserExport");
                }
            }
        }

        public DelegateCommand ExportCommand { get; set; }

        public IEnumerable ExportItems
        {
            get { return this._exportItems; }
            set
            {
                if (this._exportItems != value)
                {
                    this._exportItems = value;
                    this.OnPropertyChanged("ExportItems");
                }
            }
        }

        public IEnumerable Products
        {
            get { return this._products; }
            set
            {
                if (this._products != value)
                {
                    this._products = value;
                    this.OnPropertyChanged("Products");
                }
            }
        }

        public QueryDescriptor QueryDescriptor
        {
            get
            {
                return this._queryDescriptor;
            }
            set
            {
                if (this._queryDescriptor != value)
                {
                    if (this._queryDescriptor != null)
                        this._queryDescriptor.QueryChanged -= new System.EventHandler(OnQueryChanged);

                    this._queryDescriptor = value;
                    this._queryDescriptor.QueryChanged += new System.EventHandler(OnQueryChanged);

                    this.OnPropertyChanged("QueryDescriptor");
                }
            }
        }

        public void ExecuteExportCommand(object parameter)
        {
            Intersoft.Client.Data.ComponentModel.QueryDescriptor queryDescriptor = this.QueryDescriptor.CreateCopy(true, true, false); // copy the query descriptor, but exclude the page descriptor
            var query = this.Manager.GetProductsQuery().OrderBy(p => p.ProductID).Parse(queryDescriptor);

            this.Manager.Load(
               query,
               op =>
               {
                   if (op.IsComplete)
                   {
                       Intersoft.Client.Data.ComponentModel.PagedCollectionView current = this.Products as Intersoft.Client.Data.ComponentModel.PagedCollectionView;
                       Intersoft.Client.Data.ComponentModel.PagedCollectionView exportedItems = new Intersoft.Client.Data.ComponentModel.PagedCollectionView(op.Entities);

                       exportedItems.CopyDefinitionsFrom(current, true, false, false, false);
                       this.ExportItems = exportedItems; // supply the export process with correct collection.
                   }
                   else
                   {
                       MessageBox.Show(op.Error.ToString());
                   }
               },

               true);            
        }

        public virtual void LoadProducts()
        {
            if (Intersoft.Client.Framework.ISControl.IsInDesignModeStatic)
                return;

            var query = this.Manager.GetProductsQuery().OrderBy(p => p.ProductID).Parse(this.QueryDescriptor);
            query.IncludeTotalCount = true;

            this.Manager.Load(
               query,
               op =>
               {
                   if (op.IsComplete)
                   {
                       this.Products = new Intersoft.Client.Data.ComponentModel.PagedCollectionView(op.Entities);
                       this.QueryDescriptor.PageDescriptor.TotalItemCount = op.TotalEntityCount;
                   }
                   else
                   {
                       MessageBox.Show(op.Error.ToString());
                   }
               },

               true);
        }

        private void OnQueryChanged(object sender, System.EventArgs e)
        {            
            this.LoadProducts();
        }
    }
}
View Copy Code
    


<UserControl x:Class="HowToSamples.Exporting"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Intersoft="http://intersoft.clientui.com/schemas"
    xmlns:ViewModels="clr-namespace:HowToSamples.ViewModels"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    
    <Grid x:Name="LayoutRoot" Background="White">
        <Grid.DataContext>
            <ViewModels:ExportingViewModel/>
        </Grid.DataContext>
        <Intersoft:UXGridView AutoGenerateColumns="False" QueryOperation="Server"
                              CanUserPage="True" PageSize="20"                              
                              ItemsSource="{Binding Products}" 
                              SortDescriptors="{Binding QueryDescriptor.SortDescriptors, Mode=TwoWay}"
                              PageDescriptor="{Binding QueryDescriptor.PageDescriptor}"                              
                              CanUserExport="{Binding CanUserExport}"                              
                              ExportCommand="{Binding ExportCommand}"
                              ExportItems="{Binding ExportItems}">

        <Intersoft:UXGridView.GroupDescriptors>
            <Intersoft:UXGridViewGroupDescriptor PropertyName="CategoryID"/>
        </Intersoft:UXGridView.GroupDescriptors>

        <Intersoft:UXGridView.Columns>
            <Intersoft:UXGridViewTextColumn Header="Category ID" Binding="{Binding CategoryID}"/>
            <Intersoft:UXGridViewTextColumn Header="Product ID" Binding="{Binding ProductID}" Aggregate="Count" FooterFormatString="Count = {0}"/>
            <Intersoft:UXGridViewTextColumn Header="Product Name" Binding="{Binding ProductName}"/>
            <Intersoft:UXGridViewTextColumn Header="Units In Stock" Binding="{Binding UnitsInStock}" Aggregate="Max" FooterFormatString="Max = {0}"/>
            <Intersoft:UXGridViewTextColumn Header="Unit Price" Binding="{Binding UnitPrice}" Aggregate="Avg" FooterFormatString="Avg = {0:n2}"/>
            <Intersoft:UXGridViewTextColumn Header="Units On Order" Binding="{Binding UnitsOnOrder}" Aggregate="Min" FooterFormatString="Min = {0}"/>
            <Intersoft:UXGridViewTextColumn Header="Quantity Per Unit" Binding="{Binding QuantityPerUnit}"/>
        </Intersoft:UXGridView.Columns>

        </Intersoft:UXGridView>
    </Grid>
</UserControl>

Remarks

By default, the exporting processes only the data available in the client. Therefore if you enable server paging, you might not be able to export the complete data correctly. To address this challenge, you can implement the ExportCommand in the ViewModel and provide the desired data to the ExportItems property.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

© 2012 All Rights Reserved.