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

"clear filter" default selected

6 Answers 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Sjors
Top achievements
Rank 1
Sjors asked on 08 Oct 2013, 03:52 PM
I use a RadGridView with the style shown below (Important one is FilterRow)
I have limited the amount of filter options based on the contenttype with the class shown below

step 1: when the window loads the gridview displays data (situation: only available filter is contains)
step 2:
- I enter some existing value in the filterrow
- I hit the enter key
- the grid filters the content (works ok)
step 3:
- I enter a value that does not exist
- I hit the enter key
- the grid filters the content (no results = works ok)
step 4:
- I remove the value
- I hit enter
- the grid shows all my data (=ok)

Now when I do the same thing as above, and I do not use the enter key, but I use the mouse, it behaves weird

step 1: when the window loads the gridview displays data (situation: only available filter is contains)
step 2:
- I enter some existing value in the filterrow
- I click on the the dropdown menu and it expands. 2 options are visible (Clear Filter, Contains (highlighted))
I didn't select anything yet but the grid already filters my data (=weird)
- when I click the highlighted "contains" menuoption it does not result in the dropdown menu going away (=weird)

step 3:
- I enter a value that does not exist
- I click on the dropdown menu and it expands. (same weirdness as in step 2)
- I click on the dropdown menu and select "clear filter"
the non-existing value gets removed from the textbox (=ok)
the grid does not show any data (= very weird, I would expect all my data to show now)

In order to get content back in my grid I seem to need to enter a value that exists and click the filter drop down again
(does not always seem to work though, so Im unsure what the deal is here).

from a user experience this is the main problem I'm facing right now


we use version 2013.1.403.1050 of telerik.windows.controls.gridview

<Style x:Key="RadGridViewDefault" TargetType="telerik:RadGridView"><br>
        <Setter Property="IsReadOnly" Value="True" /><br>
        <Setter Property="IsFilteringAllowed" Value="True" /><br>
        <Setter Property="AutoGenerateColumns" Value="False" /><br>
        <Setter Property="ShowColumnHeaders" Value="True" /><br>
        <Setter Property="ShowColumnFooters" Value="False" /><br>
        <Setter Property="ShowGroupPanel" Value="False" /><br>
        <Setter Property="SelectionUnit" Value="FullRow" /><br>
        <Setter Property="FilteringMode" Value="FilterRow" /><br>
        <Setter Property="CanUserDeleteRows" Value="False" /><br>
        <Setter Property="CanUserInsertRows" Value="False" /><br>
        <Setter Property="BorderThickness" Value="1" /><br>
        <Setter Property="Margin" Value="0" /><br>
        <Setter Property="RowIndicatorVisibility" Value="Collapsed" /><br>
        <Setter Property="CanUserFreezeColumns" Value="False" /><br>
        <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Hidden" /><br>
        <Setter Property="FontSize" Value="14.667" /><br>
        <Setter Property="FontFamily" Value="Calibri" /><br>
        <Setter Property="Cursor" Value="Hand" /><br>
    </Style>


   public class MyOwnCustomGridView : RadGridView
    {
        public MyOwnCustomGridView 
()
        {
            FilterOperatorsLoading += OnFilterOperatorsLoading;
            FieldFilterEditorCreated += OnFieldFilterEditorCreated;
            Filtering += OnFiltering;
            Filtered += OnFiltered;
        }

        private void OnFiltered(object sender, GridViewFilteredEventArgs e)
        {
            
        }

        private void OnFiltering(object sender, GridViewFilteringEventArgs e)
        {
            
        }

        private static void OnFilterOperatorsLoading(object sender, FilterOperatorsLoadingEventArgs e)
        {
            var baseColumn = e.Column as GridViewBoundColumnBase;

            if (baseColumn == null)
            {
                return;
            }

            if (baseColumn.DataType == typeof(string))
            {
                SetDefaultFilterOperator(e, FilterOperator.Contains);
            }
            else if (baseColumn.DataType == typeof(int) ||
                baseColumn.DataType == typeof(int?) ||
                baseColumn.DataType == typeof(PlanningTemplateType) ||
                baseColumn.DataType == typeof(CountryCode) ||
                baseColumn.DataType == typeof(TunerStatus))
            {
                SetDefaultFilterOperator(e, FilterOperator.IsEqualTo);
            }
        }

        private void FilterChanged(object sender, EventArgs e)
        {
            
        }

        private static void SetDefaultFilterOperator(FilterOperatorsLoadingEventArgs e, FilterOperator defaultFilterOperator)
        {
            e.AvailableOperators.RemoveAll(filterOperator => filterOperator != defaultFilterOperator);
            e.DefaultOperator1 = defaultFilterOperator;
            e.DefaultOperator2 = defaultFilterOperator;
        }

        private static void OnFieldFilterEditorCreated(object sender, EditorCreatedEventArgs e)
        {
            var stringFilterEditor = e.Editor as StringFilterEditor;

            if (stringFilterEditor != null)
            {
                stringFilterEditor.MatchCaseVisibility = System.Windows.Visibility.Collapsed;
            }
        }
    }

6 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 10 Oct 2013, 08:32 AM
Hi,

Do you reproduce the same issue with RadGridView and not your custom MyOwnCustomGridView? Would you please test the same on our online demos?
 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sjors
Top achievements
Rank 1
answered on 10 Oct 2013, 02:18 PM
Hi Didie, thank you for your response!

I tried to reproduce it on your demo site http://demos.telerik.com/silverlight/#GridView/Filtering
by setting the filtermode to `filterrow` and reproduce the steps i described

Sadly I was not able to reproduce the issue

Then I tried to remove all my own code from the `MyOwnCustomGridView` class 

after I did this the strange behaviour was still present.

Is it possible that this is because of a version difference or is it more likely to be a databinding issue or something else



0
Dimitrina
Telerik team
answered on 11 Oct 2013, 03:58 PM
Hi,

The data should not have such an impact.  Would you please test your solution with the latest binaries?

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Sjors
Top achievements
Rank 1
answered on 18 Oct 2013, 03:27 PM
Hi, 

I downloaded the latest silverlight 2013.3.1016.1050
I commented out the code in MyCustomRadGridView

I can still reproduce the issue.

In my viewmodel I use VirtualQueryableCollectionView as the collection to bind to
This is the helper class that I use to bind the queries to the viewmodel's VirtualQueryableCollectionView

The problem I see is that the method LoadInternal of the helperclass is not called when I press "Clear Filter" in the UI as described in my previously mentioned "step 3"

public class VirtualQueryableCollectionViewHelper<T> where T : Entity
   {
       public VirtualQueryableCollectionViewHelper(Func<QueryableXenoxContext, EntityQuery<T>> queryGenerator, QueryableXenoxContext queryableXenoxContext, XenoxGridView gridView)
       {
           QueryGenerator = queryGenerator;
           QueryableXenoxContext = queryableXenoxContext;
           GridviewControl = gridView;
           DoNothing = i => { };
 
           View = new VirtualQueryableCollectionView<T>
           {
               LoadSize = 30,
               VirtualItemCount = 100
           };
 
           View.ItemsLoading += (sender, args) => LoadInternal(args.StartIndex, args.ItemCount, DoNothing);
 
           View.FilterDescriptors.ItemChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing);
           View.SortDescriptors.CollectionChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing);
 
           if (gridView == null)
           {
               ScrollIndexIntoView = DoNothing;
           }
           else
           {
               ScrollIndexIntoView = i => gridView.ScrollIndexIntoCenterOfView(i);
           }
       }
        
       public void Load(int currentIndex, int pageSize)
       {
           LoadInternal(currentIndex, pageSize, ScrollIndexIntoView);
       }
 
 
       public void Refresh(bool scrollToIndex = false, int currentIndex = 0)
       {
           var postLoadAction = scrollToIndex ? ScrollIndexIntoView : DoNothing;
           LoadInternal(currentIndex, View.LoadSize, postLoadAction);
       }
 
       public IEnumerable<T> GetAllCollectionItems()
       {
           return QueryableXenoxContext.Load(QueryGenerator(QueryableXenoxContext)).Entities;
       }
 
       private void LoadInternal(int currentIndex, int pageSize, Action<int> onLoaded)
       {
           if (currentIndex < 0) currentIndex = 0;
            
           var entityQuery =
               QueryGenerator(QueryableXenoxContext)
                   .Sort(View.SortDescriptors)
                   .Where(View.FilterDescriptors)
                   .Skip(currentIndex)
                   .Take(pageSize);
 
           entityQuery.IncludeTotalCount = true;
 
           QueryableXenoxContext.Load(entityQuery, LoadBehavior.RefreshCurrent, lo =>
           {
               if (lo.TotalEntityCount != -1 && lo.TotalEntityCount != View.VirtualItemCount)
               {
                   View.VirtualItemCount = lo.TotalEntityCount;
               }
 
               View.Load(currentIndex, lo.Entities);
 
               onLoaded(currentIndex);
           }, null);
       }
 
        
 
        
       public VirtualQueryableCollectionView<T> View { get; private set; }
       private Action<int> DoNothing { get; set; }
       private Action<int> ScrollIndexIntoView { get; set; }
       private Func<QueryableXenoxContext, EntityQuery<T>> QueryGenerator { get; set; }
       private QueryableXenoxContext QueryableXenoxContext { get; set; }
       private XenoxGridView GridviewControl { get; set; }
   }



0
Dimitrina
Telerik team
answered on 21 Oct 2013, 02:42 PM
Hi,

Would it be possible for you to open a support ticket and attach a demo project which we can test locally? 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Pieter
Top achievements
Rank 1
answered on 09 Nov 2013, 03:13 PM
We solved the problem. 

Adding

View.FilterDescriptors.CollectionChanged += (sender, args) => LoadInternal(0, View.LoadSize, DoNothing);

to the VirtualQueryableCollectionViewHelper did the job. 


Tags
GridView
Asked by
Sjors
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Sjors
Top achievements
Rank 1
Pieter
Top achievements
Rank 1
Share this question
or