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

Grouping on a column with a converter with a Virtual item source

13 Answers 92 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Cameron
Top achievements
Rank 1
Cameron asked on 20 Jan 2014, 12:20 PM
Hey, I'm currently having an issue with grouping not working with a column converter, when bound to a VirtualQueryableCollectionView.
When grouping a column with a converter in its databinding (by dragging the column header over the grouping panel), the values displayed are not the converted values, but the underlying values on my model. What is odd, is that the converted values are displayed in the grid, and all the column filtering (with the distinct value filters) are all working as expected. That is, they are having their values run through a converter.

Here is a sample of our code:

Xaml:
<telerik:RadGridView ItemsSource="{Binding QueryableRiskEvents}" AutoGenerateColumns="False" IsReadOnly="True" ">
    <telerik:RadGridView.Columns>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding risk_id}" Header="ID"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding equipment_code}" Header="Equipment"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding risk_description}" Header="Description"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding start_date}" Header="Start"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding end_date}" Header="End"/>
        <telerik:GridViewDataColumn DataMemberBinding="{Binding risk_status, Converter={StaticResource StatIntToString}}" Header="Status"/>

C# (on our viewmodel):
public VirtualQueryableCollectionView QueryableRiskEvents
{
            get
            {
                var query = Repository.Entities.RiskEvents.OrderBy(r => r.start_date);
                _queryableRiskEvents = new VirtualQueryableCollectionView(query, typeof(RiskEvent))
                {
                    LoadSize = 10,
                };
                return _queryableRiskEvents;
            }
        }

C# (the converter):
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
            return "hello";
        }
 
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
            return value;
    }


With this simplified example, grouping by our Status column shows the underlying integers, rather than multiple "hello" strings. 

I have tried just binding the ItemSource to the IQueryable directly (without wrapping it in the VirtualQueryableCollectionView), and the same problem occurs. However, the grouping works perfectly if bound to an IEnumerable source (but fetches all db results at once).
 
I'd greatly appreciate any tips on how we can get the expected behaviour working (as it already does with the filtering).

13 Answers, 1 is accepted

Sort by
0
Cameron
Top achievements
Rank 1
answered on 21 Jan 2014, 12:30 AM
An additional, and possibly related issue, is that grouping with 2 or more columns with converters results in dozens of "InvalidCastException"s being thrown by Telerik.Windows.Data.dll when the groups are expanded.
0
Cameron
Top achievements
Rank 1
answered on 21 Jan 2014, 01:48 AM
Update: I've created a sample project using the northwind database that demonstrates the issue, just make sure to correctly set up the DB Connection with the Northwind.mdf
http://businessimpactinc.com/install-northwind-database/

Here is the sample project:
https://www.dropbox.com/s/vv6765snxp3rmkv/Sample.zip

The converter is on the column binding for CustomerID, and does not group correctly.

0
Yoan
Telerik team
answered on 23 Jan 2014, 01:08 PM
Hi Cameron,

Actually, this would be an expected behaviour since IValueConverters are only used for presentation purposes. They play absolutely no part in the data engine the grouping is always performed on raw data values in the data engine. I can suggest you to check this forum thread where this question has already been discussed.

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Cameron
Top achievements
Rank 1
answered on 23 Jan 2014, 01:18 PM
I understand that, and have read the thread you've linked (and others) but they refer to I different issue. Let me clarify:

I don't want the grouping behaviour to be any different. The groups are determined by the unconverted value, I understand that, however the UI should never be displaying the underlying values. In my specific case, the unconverted "status" integers mean nothing to the user, and must be run through a simple converter to mean anything useful. Binding with the converter means that I:
1. See the converted values in the grid
2. See the converted values in the distinct filter (from the dropdown of the column)

However when grouping, the unconverted integers are shown, and the converter is not run at all.

The bug I am describing is specific to IQueryables. As I stated earlier, binding to an IEnumerable has the grouping values run through the converter (which leads me to believe this is a bug in how the gridview binds to IQueryables). Please see the sample project I uploaded to better understand what I am describing.

0
Dimitrina
Telerik team
answered on 28 Jan 2014, 02:59 PM
Hi,

You can check the "Group By Formatted Value" WPF Demo on how the converter should be respected. Here you can also find the same demo for Silverlight.

I have tested your demo project and indeed I am able to observe the result as you report it.
You say it works fine when binding to IEnumerable, may I ask you share how have you tested it? I tested setting the ItemsSource to this collection:
public IEnumerable<Customer> QueryableCustomers2
{
    get
    {
       return context.Customers.OrderBy(c => c.CustomerID);
    }
}

I got the same result. The original underlying values were displayed in the group rows.

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Cameron
Top achievements
Rank 1
answered on 01 Feb 2014, 04:48 AM
So binding to an IEnumerable works, provided the full list of items is returned first (but obviously this defeats the purpose of binding to a virtual source).

This works (grouping runs through the converter):

public IEnumerable<Customer> QueryableCustomers2
{
    get
    {
       return context.Customers.OrderBy(c => c.CustomerID).ToList();
    }
}


Whereas, this does NOT work (grouping does not run through converter)

public IEnumerable<Customer> QueryableCustomers3
{
    get
    {
       return context.Customers.OrderBy(c => c.CustomerID);
    }
}

0
Cameron
Top achievements
Rank 1
answered on 04 Feb 2014, 11:26 PM
Is there any progress on this issue? Or plans to resolve it? This is a very important issue for our client, and we don't want to have to re-implement filtering/sorting/grouping into our repository layer with fully instantiated List results, just so these converters aren't ignored.
0
Dimitrina
Telerik team
answered on 05 Feb 2014, 04:27 PM
Hello,

I was able to reproduce the issue locally and I am afraid that currently I cannot suggest a solution.

I am going to further investigate what the difference in our code for both the scenarios is and contact you back with a further information. 

Regards,
Didie
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
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
Cameron
Top achievements
Rank 1
answered on 17 Feb 2014, 12:10 AM
Just wondering if there has been any progress on this issue? Or whether we should start implementing the filtering ourselves?
0
Dimitrina
Telerik team
answered on 17 Feb 2014, 11:56 AM
Hello,

This functionality is not currently supported and I cannot commit to a time frame when it could be. My suggestion is to indeed consider changing of the implementation yourself so that you could achieve your goal.

Regards,
Didie
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Dimitrina
Telerik team
answered on 17 Feb 2014, 04:20 PM
Hi,

I am writing to inform you I have debugged the code in details and I am afraid the current behavior would be the expected one and it cannot be currently changed. The reason is that internally grouping in RadGridView is performed through building an LINQ Expression relying that the data is Queryable.

Regards,
Didie
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

0
Cameron
Top achievements
Rank 1
answered on 18 Feb 2014, 06:26 AM
I still feel as though you are misunderstanding the core of the issue. We are not trying to change any of the grouping functionality. The same groups should be appearing, just with a different name on the UI (exactly how the filtering works). 

I don't understand how having converted values shown in both the grid, and the dropdown filter, but unconverted values when grouped could possibly be expected behaviour. The issue is purely to do with the UI not converting the values, not anything to do with the grouping behaviour, or how the grouping is translated into a query. 
0
Dimitrina
Telerik team
answered on 18 Feb 2014, 10:03 AM
Hello,

I understand your concern and indeed the idea of the converter is for display purposes only. Still, currently this behavior cannot be changed as it is by design.
I have logged the issue for a further investigation.
 
Regards,
Didie
Telerik
Tags
GridView
Asked by
Cameron
Top achievements
Rank 1
Answers by
Cameron
Top achievements
Rank 1
Yoan
Telerik team
Dimitrina
Telerik team
Share this question
or