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

Grouping and Filtering

9 Answers 98 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Brett Pierce
Top achievements
Rank 1
Brett Pierce asked on 15 Apr 2010, 03:48 PM
Hi

I have the following :

                <RadControls:GridViewDataColumn Header="Barcode Number" DataMemberPath="BarcodeNumber"  /> 
                <RadControls:GridViewDataColumn Header="Status" IsGroupable="True" IsFilterable="True"  
                                                DataMemberBinding="{Binding ParcelStatus.StatusName}"                                                 
                                                /> 
 

Am I doing something wrong?

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 15 Apr 2010, 03:51 PM
Hi Brett Pierce,

I believe this sholud be the DataMemberPath property,
please replace it with something like :
DataMemberBinding ="{Binding BarcodeNumber}"

Best wishes,
Pavel Pavlov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brett Pierce
Top achievements
Rank 1
answered on 15 Apr 2010, 05:24 PM
Hi Pavel,

I have tried using the DataMemberPath as well, but it didnt solve the Grouping/Filtering issue.
The problem occurs when the column is bound to the a property of a property.

eg. Consider the following schema: Employee has a Department property and Department has a Name property
If I bind the Grid to a collection of Employees and in turn bind the column to the Name property of the Department "{Binding Department.Name}", the value displays, but the column cannot be grouped or filtered.

Thanks
0
Vlad
Telerik team
answered on 16 Apr 2010, 06:39 AM
Hi,

Can you post more info about the grid version?

Best wishes,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Brett Pierce
Top achievements
Rank 1
answered on 20 Apr 2010, 11:33 AM
Hi,

The version of the Telerik.Windows.Controls.GridView assembly is 2009.2.812.1030.

Thanks
0
Vlad
Telerik team
answered on 20 Apr 2010, 11:44 AM
Hi,

This is Q2 2009 SP1 - can you please update at lease to Q3 2009? Of course it will be better if you use our latest official release Q1 2010.

Kind regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Phil
Top achievements
Rank 1
answered on 16 May 2010, 03:28 AM
I'm also having a similar problem with Grouping, Filtering or Sorting with Silverlight 4 RTM and the latest Telerik SL4 binaries when using a Rad GridView control that involves binding to and indexed property.

In my case, each row in the radgrid is from an entity that also has a dictionary <int, ChildEntity> that gets populated with a reference to its child collection.  I'm trying to use the new SL4 dictionary binding to display a property of one of the child rows in the same row as the parent properties (essentially flattening a one-to-many relationship).  I'm creating columns in code-behind and have used the DataMemberBinding to set the path for the GridViewDataColumn.

All columns display correctly when the data is retrieved and the grid loads.  I do notice in the output window that even though the data displays, I see lots of connect errors like this:

System.Windows.Data Error: Failed to connect to index '266' in object 'System.Collections.Generic.Dictionary`2[System.Int32,Test_2010_SLWeb.MyChildDictionary]' (type 'System.Collections.Generic.Dictionary`2[System.Int32,Test_2010_SLWeb.MyChildDictionary]'). BindingExpression: Path='MyChildDictionary[266].StringValue' DataItem='Test_2010_SLWeb.MyParentEntity' (HashCode=25666); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String').


If I click on the column header for the dictionary-bound column (to sort it) or drag it to the grouping header or click the filter icon, the page throws an error like:
System.Windows.Data Error: Cannot get 'Header' value (type 'System.Object') from 'Telerik.Windows.Controls.GridView.GroupViewModel' (type 'Telerik.Windows.Controls.GridView.GroupViewModel'). BindingExpression: Path='Header' DataItem='Telerik.Windows.Controls.GridView.GroupViewModel' (HashCode=37656977); target element is 'System.Windows.Controls.ContentPresenter' (Name=''); target property is 'Content' (type 'System.Object').. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at lambda_method(Closure , MyParentEntity)
   at System.Linq.Lookup`2.Create[TSource](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at System.Linq.GroupedEnumerable`3.GetEnumerator()
   at System.Linq.Buffer`1..ctor(IEnumerable`1 source)
   at System.Linq.OrderedEnumerable`1.<GetEnumerator>d__0.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at Telerik.Windows.Data.Group.InitializeSubgroups()
   at Telerik.Windows.Data.Group.get_Subgroups()
   at Telerik.Windows.Data.GroupExtensions.Leaves(IGroup group)
   at Telerik.Windows.Controls.GridView.GroupViewModel.GetHeaderFromColumn()
   at Telerik.Windows.Controls.GridView.GroupViewModel.get_Header()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, BindingFlags invokeAttr, Binder binder, Object[] index, CultureInfo culture)
   at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)
   at System.Windows.CLRPropertyListener.get_Value()
   at System.Windows.PropertyAccessPathStep.ConnectToPropertyInSource(Boolean isSourceCollectionViewCurrentItem). 
 
If however, I first group by a property on the parent entity (non-indexed) and then add the child property to the grouping as the second group column (can't be the first), it doesn't throw an error and does appear to group the data but the data is actually duplicated (once for each grouping column I'm guessing?).

Any ideas?
0
Vlad
Telerik team
answered on 17 May 2010, 07:16 AM
Hello Phil,

Please open support ticket and send us an example project where we can reproduce and debug these problems.

Regards,
Vlad
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Phil
Top achievements
Rank 1
answered on 19 May 2010, 06:21 AM
I found the problem and have opened a support ticket (311133) with a sample app (not sure if this is a real bug or just the way it has to be).

It turned out that for some of my parent entities, they didn't have any child entities but I was still newing up the dictionary but not adding any entries.  If I leave the dictionary NULL, the grid groups and sorts correctly.

I also noticed that if I was binding to three child rows and if some parents didn't have all three rows but had at least one row (so that after I fixed the new but empty dictionary problem you had at least one dictionary entry), that you'd get the same behavior (index not found).  If I add the key for the missing child rows and set the value to NULL, the grid groups and sorts correctly.

However, if the child rows sub-property that I'm binding to isn't a string, you can display the data but grouping throws a "no coercion operator exists between string and int (or string and datetime)" and sorting works but the filter doesn't (it opens the dialog and you can click on the filter values but no filtering occurs).   However I realized that I was creating the column as a string column (since the child column in the child table is actually a string but can be dynamically typed by our code to be used as other datatypes) rather than the dynamic typed usage.  If I used Nullable<int> for example, then the grouping works.  As an aside, if I just let the radgrid decide what datatype it is binding to, it works as well.
0
Maya
Telerik team
answered on 20 May 2010, 12:31 PM
Hello Phil,

When using the class Dictionary<TKey, TValue>, you should be aware of the fact that it only works in case a "key" is provided. Furthermore, when there is no element with a key specified, "KeyNotFoundExceptions" is thrown. In your case, you are trying to fill some of the Child Columns and to left the others empty. And the empty ones are those causing the problem.
A possible solution is to create your own custom class that implements the IDictionary interface or to inherit the Dictionary class and override its methods. Then what you need is to ensure that when there is no key and no value, it will return null. In that case no exception will be thrown. 

 

All the best,
Maya
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
GridView
Asked by
Brett Pierce
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Brett Pierce
Top achievements
Rank 1
Vlad
Telerik team
Phil
Top achievements
Rank 1
Maya
Telerik team
Share this question
or