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

[Solved] FilteringControl does not appear when using CellTemplate

6 Answers 191 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Aaron Hanusa
Top achievements
Rank 1
Aaron Hanusa asked on 22 Sep 2010, 05:55 PM
Here is my code.  Any thoughts?

                        <telerik:GridViewDataColumn Header="Details">
                            <telerik:GridViewDataColumn.FilteringControl>
                                <views:DetailsSearchControl></views:DetailsSearchControl>
                            </telerik:GridViewDataColumn.FilteringControl>
                            <telerik:GridViewDataColumn.CellTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Horizontal">
                                        <TextBlock Text="{Binding Path=TransactionDetail}" VerticalAlignment="Center" Margin="5,0,0,0" />
                                        <Button Name="editDetailButton" Click="editDetailButton_Click" Margin="10,0,5,0" >...</Button>
                                    </StackPanel>
                                </DataTemplate>
                            </telerik:GridViewDataColumn.CellTemplate>
                        </telerik:GridViewDataColumn>

6 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 23 Sep 2010, 07:37 AM
Hello,

 I've just tried this however everything worked as expected. Please check the attached application for reference. 

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
Aaron Hanusa
Top achievements
Rank 1
answered on 23 Sep 2010, 03:36 PM
Thanks Vlad,

I actually figured out what the issue was, and I'm wondering if this is a bug with the grid or by design?  This is not my true object model, but for sake of brevity, here is what the issue is.

public class Person
{
   public AddressBase Address { get; set; }
}

public abstract class AddressBase
{
   public string Street { get; set; }
   ....
}


Then, each concrete implementation of AddressBase will override ToString(), and display the full address based on the properties defined in each Address class.

Then in the column, I was referencing the Address like so, but this didn't work (the value shows up in the cells, BUT the filter icon does not show up in this scenario):

<telerik:GridViewDataColumn Header="Details" DataMemberBinding="{Binding Path=Address}">

What I tried next was to provide another property of AddressBase, like so:

public abstract class AddressBase
{
   public string Street { get; set; }
   public string StringValue { get { return this.ToString() ; }}
}

Then I changed the xaml like so:

<telerik:GridViewDataColumn Header="Details" DataMemberBinding="{Binding Path=Address.StringValue}">

And this fixed my issue.

I would rather not have to expose StringValue from AddressBase, but it works for now.  It would be nice to be able to get this to work by binding directly to the object and having the binding invoke ToString() on my behalf.

If you would like to test this, I would recommend modifying the sample that you sent me, and exposing an object from MyObject, and replacing the binding to reference the object instead of "Name".  You will see the behavior that I speak of.

Alternatively, I have changed your sample project to display the behavior that I speak of.  Please let me know if you would like to see it and how I can get it to you.

Thanks again!
0
Vlad
Telerik team
answered on 23 Sep 2010, 03:54 PM
Hi,

 You can bind directly to desired sub property:

<telerik:GridViewDataColumn DataMemberBinding="{Binding Address.Street}">

Or you implement IComparable<> and/or IEquatable<T> for this class. 

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
Aaron Hanusa
Top achievements
Rank 1
answered on 23 Sep 2010, 04:50 PM
Nope, you missed my point.  You cannot specify Address.Street, because the members are not known until runtime.  Remember that Address is abstract, and concrete Address implementations (USAddress, CanadaAddress) will contain members unique to them. 

Therefore, for example, you cannot specify Address.Province, because Province would be unique to a CanadaAddress.

This is why I override ToString() on each class, so that it can display the whole address, polymorphically.

You really should take a look at my code.  Maybe you'll understand the issue better.

Thanks!
0
Accepted
Vlad
Telerik team
answered on 24 Sep 2010, 06:16 AM
Hi ,

 You cannot sort, group or filter such type since if you do not implement IComparable<> and/or IEquatable<T>. If you cannot filter on some type RadGridView will not show filtering UI. 

Sincerely yours,
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
Aaron Hanusa
Top achievements
Rank 1
answered on 24 Sep 2010, 02:17 PM
Vlad, I see what you're saying now.  I don't personally need to utilize members of IComparible or IEquatable, but apparently, the column cares about the bound object implementing one of those interfaces.  If the column is not bound to an object that implements one of those interfaces, then the filter icon will not appear.

Thanks again.
Tags
GridView
Asked by
Aaron Hanusa
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Aaron Hanusa
Top achievements
Rank 1
Share this question
or