Thursday, November 4, 2010

silverlight - domain data source, multiple filter, sort, paginate datagrid

below is the XAML of the page that used for the purpose. you can see the domain datasource, the xlmns classes decleration on the top, multiple filters using two text boxes, datagrid, data pager and other related things.

Please note that the bottom two buttons has not been implemented yet for the details and edit of the record.


        
         <navigation:Page xmlns:my="clr-namespace:CRUD.Controls"  xmlns:riaControls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"
             xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" 
                   xmlns:ds="clr-namespace:CRUD.Web.Services"
  x:Class="CRUD.Home"
  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:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
  mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" 
  Style="{StaticResource PageStyle}">

  <Grid x:Name="LayoutRoot">
        <riaControls:DomainDataSource Name="ddsStates" LoadSize="100" QueryName="GetStateProvinces" AutoLoad="True" >
            <riaControls:DomainDataSource.DomainContext>
                <ds:AdvDomainContext />
            </riaControls:DomainDataSource.DomainContext>
           
            <riaControls:DomainDataSource.SortDescriptors>
                <riaControls:SortDescriptor PropertyPath="CountryRegionCode" Direction="Ascending"></riaControls:SortDescriptor>
            </riaControls:DomainDataSource.SortDescriptors>
           
            <riaControls:DomainDataSource.FilterDescriptors>
                <riaControls:FilterDescriptor
                    PropertyPath="CountryRegionCode"
                    Operator="Contains"
                    IgnoredValue=""
                    Value="{Binding ElementName=CountryCodeText, Path=Text}">
                   
                </riaControls:FilterDescriptor>

                <riaControls:FilterDescriptor
                    PropertyPath="Name"
                    Operator="Contains"
                    IgnoredValue=""
                    Value="{Binding ElementName=NameText, Path=Text}">

                </riaControls:FilterDescriptor>
            </riaControls:DomainDataSource.FilterDescriptors>

        </riaControls:DomainDataSource>
        <ScrollViewer x:Name="PageScrollViewer" Style="{StaticResource PageScrollViewerStyle}" >

      <StackPanel x:Name="ContentStackPanel" Style="{StaticResource ContentStackPanelStyle}">

        <TextBlock x:Name="HeaderText" Style="{StaticResource HeaderTextStyle}"
                           Text="{Binding Path=ApplicationStrings.HomePageTitle, Source={StaticResource ResourceWrapper}}"/>
        <TextBlock x:Name="ContentText" Style="{StaticResource ContentTextStyle}"
                           Text="Home page content"/>

                <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                    <TextBlock VerticalAlignment="Center" Text="Country Code Filter : " />
                    <TextBox x:Name="CountryCodeText" Width="75" FontSize="11" Margin="4" />

                    <TextBlock VerticalAlignment="Center" Text="Name Filter : " />
                    <TextBox x:Name="NameText" Width="75" FontSize="11" Margin="4" />
                </StackPanel>

                <my:BusyIndicator IsBusy="{Binding IsBusy, ElementName=ddsStates}"  DisplayAfter="0:0:0.1">
                    <my:BusyIndicator.BusyContentTemplate>
                        <DataTemplate>
                            <StackPanel Name="a" Margin="4">
                                <TextBlock Text="Loading Grid Values . . ." />
                            </StackPanel>
                          
                        </DataTemplate>
                    </my:BusyIndicator.BusyContentTemplate>
                   
                <sdk:DataGrid Name="dgStates" Height="Auto" IsReadOnly="True" ItemsSource="{Binding Data, ElementName=ddsStates}" >
                   
                </sdk:DataGrid>
                </my:BusyIndicator>
                <sdk:DataPager PageSize="5" Source="{Binding Data, ElementName=ddsStates}" Margin="0,0,0,0" ></sdk:DataPager>

               
             
                </StackPanel>
           

    </ScrollViewer>
  </Grid>

</navigation:Page>

No comments:

Post a Comment