Select to view content in your preferred language

Unable to make datapager work when binded to a silverlight datagrid

702
3
10-07-2011 06:44 AM
sairam1
Emerging Contributor
Unable to make datapager work when binded to a silverlight datagrid, could you please provide suggestions on this as how it can  done ?

this is the non-spatial data (table) published at the rest end point : http://srimpa22/ArcGIS/rest/services/Structures/MapServer/10 - which i used for binding data on the datgrid.

please find below the xaml.cs & xaml code :

    Mainpage.Xaml.cs

        public MainPage()
        {
            InitializeComponent();
            QueryTask queryTask =
             new QueryTask("http://srimpa22/ArcGIS/rest/services/Structures/MapServer/10");
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
            query.OutFields.Add("*");
            query.Where = "1=1";
            queryTask.ExecuteAsync(query, "initial");

            PagedCollectionView tempListView = new PagedCollectionView("http://srimpa22/ArcGIS/rest/services/Structures/MapServer/10");            QueryDetailsDataGrid.ItemsSource = tempListView;
            TempDataGridDataGridPager.Source = tempListView;        
        }


Mainpage.Xaml

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition></RowDefinition>
            <RowDefinition Height="Auto">
            </RowDefinition>
        </Grid.RowDefinitions>
              <slData:DataGrid x:Name="QueryDetailsDataGrid"  Grid.Row="0" AutoGenerateColumns="False" HeadersVisibility="Column" Background="White"
                            VerticalScrollBarVisibility="Disabled" IsReadOnly="True" Canvas.Left="10" Canvas.Top="50" Height="140" Width="530">
            <slData:DataGrid.Columns>
                <slData:DataGridTextColumn x:Name ="one"  Width="85" CanUserSort="True"  Binding="{Binding Attributes[COUNTY]}" Header="County"/>              
            </slData:DataGrid.Columns>
        </slData:DataGrid>
        <slData:DataPager x:Name="TempDataGridDataGridPager" Grid.Row="1"  DisplayMode="FirstLastPreviousNext" PageSize="5"
                          Source ="{Binding ItemSource, ElementName=QueryDetailsDataGrid}" Canvas.Top="218" Canvas.Left="3">
        </slData:DataPager>
        </Grid>
</UserControl>


Thanks,

Appreciate for your suggestions.

Have a wonderful long weekend!
0 Kudos
3 Replies
JenniferNery
Esri Regular Contributor
This Silverlight forum thread seem related: http://forums.silverlight.net/t/122575.aspx/1

http://msdn.microsoft.com/en-us/library/system.windows.data.pagedcollectionview%28v=vs.95%29.aspx

PagedCollectionView must be initialized with the data.
0 Kudos
sairam1
Emerging Contributor
Jennifer,

Here, with the arc gis rest services - i am unable to understand how can i intialize the pagecollectionview  with the data, that is displayed on the silverlight datagrid based on query task mentioned below.

QueryTask queryTask =
new QueryTask("http://srimpa22/ArcGIS/rest/services/Structures/MapServer/10");
queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
queryTask.Failed += QueryTask_Failed;

ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
query.OutFields.Add("*");
query.Where = "1=1";
queryTask.ExecuteAsync(query, "initial");


I would appreciate if you can elaborate on it.

The intialization of the data that i did in pagecollectionview below - is it wrong?

PagedCollectionView tempListView = new PagedCollectionView("http://srimpa22/ArcGIS/rest/services/Structures/MapServer/10");


Thanks in advance, for providing your suggestions.
0 Kudos
AnhTruong
Emerging Contributor
Hello,

I searched for paging solution in ArcGIS for Silverlight dataGrid and came up your posting question a year ago. Did you find out the solution???
In my dataPager, I can see how many pages but when I navigate using next, previous the data not display by page size. Any idea how to correct it?  Please respond if you know something. Thanks in advance.

Here are my codes as following:

MainPage.xaml.cs

           QueryTask queryTask = new QueryTask("http://egis/ArcGIS/rest/services/SCH/MapServer/0");
            queryTask.ExecuteCompleted += QueryTask_ExecuteCompleted;
            queryTask.Failed += QueryTask_Failed;

            ESRI.ArcGIS.Client.Tasks.Query query = new ESRI.ArcGIS.Client.Tasks.Query();
            query.Text = TaskNumberTextBox.Text;
            query.OutFields.Add("*");
            query.Where = "1=1";
            queryTask.ExecuteAsync(query);
           

            QueryDetailsDataGrid.ItemsSource = new PagedCollectionView("http://egis/ArcGIS/rest/services/SCH/MapServer/0");
            SCHPager.Source = QueryDetailsDataGrid.ItemsSource;

MainPage.xaml
    
             <sdk:DataPager x:Name="SCHPager" Grid.Column="1" Grid.Row="1" VerticalAlignment="Bottom" Background="#FF333333" Foreground="#FFE5E5E5" BorderBrush="Black" Source ="{Binding Path = ItemsSource, ElementName=QueryDetailsDataGrid}" PageSize="30" />

Anything wrong in my code behind? Thanks.
0 Kudos