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

[Solved] GridViewComboBoxColumn Bind to Object, filter and grouping missing

8 Answers 202 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.
Andrew Chan
Top achievements
Rank 1
Andrew Chan asked on 10 Jun 2010, 04:01 AM

Hi there,

When I bind GridViewComboBoxColumn to an object type attribute in my class, (e.g. gender in my example), the column filter and grouping does not work (filter funnel disappeared in the column header and the column cannot be dragged to the grouping area) in the GridView. Could you show me how to get it back? Thanks.

    public class Model  
    {  
        private string _id;  
        private string _name;  
        private GenericLookUp _gender;  
 
        [Display(Name = "Model ID")]  
        [Editable(false)]  
        public string id  
        {  
            get 
            {  
                return _id;  
            }  
            set 
            {  
                _id = value;  
            }  
        }  
 
        [Display(Name = "Model Name")]  
        [Required(ErrorMessage = "Model Name is required")]  
        public string name  
        {  
            get 
            {  
                return _name;  
            }  
            set 
            {  
                Validator.ValidateProperty(value, new ValidationContext(thisnullnull) { MemberName = "name" });  
                _name = value;  
            }  
        }  
          
         
        public GenericLookUp gender  
        {  
            get 
            {  
                return _gender;  
            }  
            set 
            {  
                _gender = value;  
            }  
        }  
    } 


Regards,
Andrew

8 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Jun 2010, 07:34 AM
Hi Andrew,

 You are missing most probably DataMemberBinding declaration for this column. Can you post the column XAML? You can check also our demo for various binding scenarios.

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
Andrew Chan
Top achievements
Rank 1
answered on 10 Jun 2010, 07:37 AM
This is my columns xaml. Thanks.

<telerikGrid:GridViewComboBoxColumn DataMemberBinding="{Binding gender}" DisplayMemberPath="displayValue" SelectedValueMemberPath="displayValue"  ItemsSource="{Binding GenderOption, Source={StaticResource LookupViewModel}}"/> 
0
Vlad
Telerik team
answered on 10 Jun 2010, 07:41 AM
Hi Andrew,

 Can you post more info about GenericLookUp type? The grid can sort for example any IComparable.

Greetings,
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
Andrew Chan
Top achievements
Rank 1
answered on 10 Jun 2010, 07:44 AM
Thanks for your prompt response. Here it is.
    public class GenericLookUp  
    {          
            int _id;  
            public int id   
            {  
                get   
                { return _id; }  
 
                set 
                { _id = value; }  
            }  
 
            string _displayValue;  
            public string displayValue  
            {  
                get 
                { return _displayValue; }  
 
                set 
                { _displayValue = value; }  
            }  
 
 
            public GenericLookUp(int _id, string _displayValue)  
            {  
                this.id = _id;  
                this.displayValue = _displayValue;  
            }  
 
            public GenericLookUp()  
            {                  
            }  
    } 
0
Accepted
Vlad
Telerik team
answered on 10 Jun 2010, 07:48 AM
Hello Andrew,

 You need to implement IComparable if you want for example this column to be sortable. Otherwise you can bind directly to your sub property:

DataMemberBinding="{Binding gender.displayValue}"

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
Andrew Chan
Top achievements
Rank 1
answered on 10 Jun 2010, 08:01 AM
Cool, it works great !! Thanks.
0
Amit Patel
Top achievements
Rank 1
answered on 18 Aug 2010, 02:53 PM

HI Vlad,
I have a similar situation where filtering is missing when bind to sub property. I tried to bind to sub property but nothing get displayed. if I bind the way showned below then the only thing is not working is filtering. it is missing.  Can you let me know what i am missing here? Thanks Amit

 

 

 

 

<telerik:GridViewComboBoxColumn HeaderTextAlignment="Center" Header="Resource"

 

 

 

GroupMemberPath="Resource.Name" DisplayMemberPath="Name" DataMemberBinding="{Binding Resource, Mode=TwoWay}" UniqueName="Resource"/>

 

public

 

 

partial class ResourcingTemplate : IEntity

 

 

 

 

 

{

    public

 

 

Resource Resource {get;set;}
}

public partial class Resource
{
    public Guid Id {get; set;}
    public string Name {get; set;}
}

 

 

 

0
Maya
Telerik team
answered on 20 Aug 2010, 03:24 PM
Hello Amit Patel,

You may take a look at this blog post, where you will find detailed information as well as a sample project demonstrating how to filter a GridViewComboBoxColumn. 

Greetings,
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
Andrew Chan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Andrew Chan
Top achievements
Rank 1
Amit Patel
Top achievements
Rank 1
Maya
Telerik team
Share this question
or