This is a migrated thread and some comments may be shown as answers.

paging and clearing filters

4 Answers 85 Views
DataPager
This is a migrated thread and some comments may be shown as answers.
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
David Ocasio asked on 02 Jul 2012, 08:00 PM
I have what i beleive to be a bug (2012.2.607.1050 version)
although it could be the way i am doing it

I needed a button that would clear all the filters that have been set up on a radgridview that was
fed by a domaindatasource/pager

I used code that was posted by the admin Ross for clearing the filters
Private Sub btnClear_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles btnClear.Click
    radGridView.FilterDescriptors.SuspendNotifications()
    For Each column In radGridView.Columns
        If column.FilteringControl IsNot Nothing Then
        Else
            column.ClearFilters()
        End If
    Next
    radGridView.FilterDescriptors.ResumeNotifications()
End Sub

What i found was some unusal behavior where multiple loads were being started on the DDS.

In an effort to demonstarte this behavior i authored a short demo/test against the northwind database
I removed the domaindatasource and replaced it with a QueryableDomainServiceCollectionView

if you filter a number of columns
Then change the page to 2 or 3 or any page except the first one
Press the clear button.

Multiple loads will be started and completed
See code and Debug Output below

is there somehting i am doing wrong
is there a better way
is it a bug (i think so)

thanks
dco

<UserControl x:Class="agTesty6.MainPage"
        mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480">
     
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
 
        <telerik:RadGridView x:Name="radGridView"
                             Grid.Row="0"
                             ItemsSource="{Binding DataView}"
                             ShowGroupPanel="False"
                             AutoGeneratingColumn="OnRadGridViewAutoGeneratingColumn"
                             IsReadOnly="True"/>
             
        <telerik:RadDataPager x:Name="radDataPager"  
                              PageSize="10"
                              Grid.Row="1"
                              AutoEllipsisMode="Both"
                              NumericButtonCount="10"
                              Source="{Binding DataView}"
                              DisplayMode="All"
                              IsTotalItemCountFixed="True"/>
        <Button Content="Clear" Grid.Row="2" Margin="4" Width="75" HorizontalAlignment="Right" x:Name="btnClear"  />
    </Grid>
</UserControl>
Imports System
Imports System.Linq
Imports System.Windows.Controls
Imports Telerik.Windows.Controls.DomainServices
Imports Telerik.Windows.Data
Partial Public Class MainPage
    Inherits UserControl
 
    Public Sub New()
        InitializeComponent()
 
        Dim domainContext As New agTesty6.Web.NorthWindDomainContext
 
        Dim query = domainContext.GetCustomers_OrderedQuery
        _DataView = New QueryableDomainServiceCollectionView(Of agTesty6.Web.Customer)(domainContext, query)
 
        Me.DataContext = Me
        _DataView.AutoLoad = True
 
    End Sub
 
    Public ReadOnly Property DataView() As QueryableCollectionView
        Get
            Return _DataView
        End Get
    End Property
    Private WithEvents _DataView As QueryableDomainServiceCollectionView(Of agTesty6.Web.Customer)
 
    Private Sub OnRadGridViewAutoGeneratingColumn(sender As System.Object, e As Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs)
    End Sub
 
    Private Sub btnClear_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles btnClear.Click
        radGridView.FilterDescriptors.SuspendNotifications()
        For Each column In radGridView.Columns
            If column.FilteringControl IsNot Nothing Then
            Else
                column.ClearFilters()
            End If
        Next
        radGridView.FilterDescriptors.ResumeNotifications()
    End Sub
 
    Private Sub _DataView_LoadedData(sender As Object, e As Telerik.Windows.Controls.DomainServices.LoadedDataEventArgs) Handles _DataView.LoadedData
        System.Diagnostics.Debug.WriteLine("Dataview Loaded Data -- " & e.Entities.Count)
    End Sub
 
    Private Sub _DataView_LoadingData(sender As Object, e As Telerik.Windows.Controls.DomainServices.LoadingDataEventArgs) Handles _DataView.LoadingData
        System.Diagnostics.Debug.WriteLine("======================")
        System.Diagnostics.Debug.WriteLine("Dataview Loading Data")
        System.Diagnostics.Debug.WriteLine(e.Query.Query)
    End Sub
End Class

======================
Dataview Loading Data
agTesty6.Web.Customer[].Where(item => item.CompanyName.ToLower().Contains("s".ToLower())).Skip(30).Take(10)
Dataview Loaded Data -- 10
======================
Dataview Loading Data
agTesty6.Web.Customer[].Take(10)
======================
Dataview Loading Data
agTesty6.Web.Customer[].Take(10)
======================
Dataview Loading Data
agTesty6.Web.Customer[].Skip(30).Take(10)
Dataview Loaded Data -- 10
Dataview Loaded Data -- 10
Dataview Loaded Data -- 10

4 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 03 Jul 2012, 07:15 AM
Hello,

Do you have this sample project targeting Northwind? Can you send it to me for debugging?

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 03 Jul 2012, 10:48 AM
Ok 
I opened support ticket 561359
So i could upload the demo solution for your review.
I referenced this forum as well as your name in the ticket.

thanks ross
dco
0
Accepted
Rossen Hristov
Telerik team
answered on 03 Jul 2012, 11:21 AM
Hi,

Can you please add this code to your source code:
Private Sub btnClear_Click(sender As Object, e As System.Windows.RoutedEventArgs) Handles btnClear.Click
    Using (_DataView.DeferRefresh())
        radGridView.FilterDescriptors.SuspendNotifications()
        For Each column In radGridView.Columns
            If column.FilteringControl IsNot Nothing Then
            Else
                column.ClearFilters()
            End If
        Next
        radGridView.FilterDescriptors.ResumeNotifications()
    End Using
End Sub

When the QDSCV is on a page different from the first one, it will try to move back to page 0 after a dramatic change occurs, i.e. filtering, that is why it may load a couple of times. If you surround the de-filtering in a DeferRefresh call all should happen in a single batch operation.

I hope this helps.

Regards,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
answered on 03 Jul 2012, 08:24 PM
Thanks ross

That does work

Had to refactor a little since my production code has a radomaindatasource as opposed to the QueryableDomainServiceCollectionView
I used in the example and the "DeferRefresh" is not exposed.

But it does work as you said.

thanks
dco
Tags
DataPager
Asked by
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Answers by
Rossen Hristov
Telerik team
David Ocasio
Top achievements
Rank 2
Iron
Veteran
Iron
Share this question
or