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

radgridview full text search

9 Answers 862 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Anatol
Top achievements
Rank 1
Anatol asked on 02 Jan 2018, 04:09 PM

Hello. I have a special classes: tbTechObject and tbTech. tbTechObject contains tbTech. When I use "full test search" it doesn`t work for column with tbTechObject items (telerik:GridViewComboBoxColumn  "ТСИ"). "full test search" work only for string columns. What have I do to "full test search" searches in column with my custom type elements? Thanks.

[global::System.ComponentModel.TypeConverter(typeof(tbTechObjectConverter))]
    public class tbTechObject : IEquatable<tbTechObject>, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private void FirePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        public int idTechObject { get; set; }
        public ObservableCollection<tbTech> nameTech { get; set; }//Items source for combobox column in radgridview. This class describe bellow
        private tbTech nTech;
        public tbTech NTech
        {
            get { return nTech; }
            set
            {
                if (this.nTech != value)
                {
                    this.nTech = value;
                    FirePropertyChanged("NTech");
                }
            }
        }
        public string serialNum { get; set; }
        public string inventNum { get; set; }
       
        public void save()
        {
            //save to db
        }
        bool IEquatable<tbTechObject>.Equals(tbTechObject other)
        {
            if (other == null)
            {
                return false;
            }
            return StringComparer.Ordinal.Equals(this.NTech.name, other.NTech.name);
        }
        public override bool Equals(object obj)
        {
            return ((IEquatable<tbTechObject>)this).Equals(obj as tbTechObject);
        }
        public override int GetHashCode()
        {
            if (this.NTech == null)
                this.NTech = this.nameTech[0];
            return this.NTech.name.GetHashCode() ^ this.idTechObject.GetHashCode();
        }
        public override string ToString()
        {
            return this.NTech.name;
        }
    }

    public class tbTechObjectConverter : System.ComponentModel.TypeConverter
    {
        public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(string))
            {
                return true;
            }
            return base.CanConvertFrom(context, sourceType);
        }
        public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            var stringValue = value as string;
            if (stringValue != null)
            {
                return new tbTechObject {  idTechObject = -1 };
            }
            return base.ConvertFrom(context, culture, value);
        }
        public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                return true;
            }
            return base.CanConvertTo(context, destinationType);
        }
        public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                return ((tbTechObject)value).ToString();
            }
            return base.ConvertTo(context, culture, value, destinationType);
        }
    }

 

/////////////////////////////////

[global::System.ComponentModel.TypeConverter(typeof(tbTechConverter))]
    public class tbTech : IEquatable<tbTech>, INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private void FirePropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
       
        public int idNameTech { get; set; }
        public string name { get; set; }
       
        public bool save()
        {
            //save to db

        }   
       
        bool IEquatable<tbTech>.Equals(tbTech other)
        {
            if (other == null)
            {
                return false;
            }
            return StringComparer.Ordinal.Equals(this.name, other.name);
        }
        public override bool Equals(object obj)
        {
            return ((IEquatable<tbTech>)this).Equals(obj as tbTech);
        }
        public override int GetHashCode()
        {
            return this.name.GetHashCode() ^ this.idNameTech.GetHashCode();
        }
        public override string ToString()
        {
            return this.name;
        }
    }
    public class tbTechConverter : System.ComponentModel.TypeConverter
    {
        public override bool CanConvertFrom(System.ComponentModel.ITypeDescriptorContext context, Type sourceType)
        {
            if (sourceType == typeof(string))
            {
                return true;
            }
            return base.CanConvertFrom(context, sourceType);
        }
        public override object ConvertFrom(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            var stringValue = value as string;
            if (stringValue != null)
            {
                return new tbTech { name = stringValue, idNameTech = -1 };
            }
            return base.ConvertFrom(context, culture, value);
        }
        public override bool CanConvertTo(System.ComponentModel.ITypeDescriptorContext context, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                return true;
            }
            return base.CanConvertTo(context, destinationType);
        }
        public override object ConvertTo(System.ComponentModel.ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                return ((tbTech)value).ToString();
            }
            return base.ConvertTo(context, culture, value, destinationType);
        }
    }

//////////////////XAML

<telerik:RadGridView x:Name="mainDG" Margin="259,0,5,5" AutoGenerateColumns="False" CanUserDeleteRows="False" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" MouseDoubleClick="mDClikMainDG" MouseRightButtonDown="mouseRBtnDownMainDG" ScrollMode="Deferred" AutomationProperties.IsRowHeader="True">
                        <telerik:RadGridView.Columns>
                            <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding IsChecked, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" EditTriggers="CellClick" AutoSelectOnEdit="True">
                                <telerik:GridViewCheckBoxColumn.Header>
                                    <CheckBox  HorizontalAlignment="Center" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
                                    </CheckBox>
                                </telerik:GridViewCheckBoxColumn.Header>
                            </telerik:GridViewCheckBoxColumn>
                            <telerik:GridViewComboBoxColumn Header="ТСИ" Width="200" EditTriggers="CellClick" ItemsSourceBinding="{Binding nameTech}" DisplayMemberPath="name" DataMemberBinding="{Binding NTech, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  SelectedValueMemberPath="{Binding NTech, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsComboBoxEditable="True" IsFilterable="True">
                               
                            </telerik:GridViewComboBoxColumn>

                            <telerik:GridViewDataColumn Header="Serial number" DataMemberBinding="{Binding serialNum}"/>
                            <telerik:GridViewDataColumn Header="Inventor number" DataMemberBinding="{Binding inventNum}"/>

 </telerik:RadGridView.Columns>
                    </telerik:RadGridView>

 

9 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 05 Jan 2018, 12:18 PM
Hi Anatol,

In order to enable searching for a GridViewComboBoxColumn, you need to set the IsLightWeightModeEnabled property of the column to True. Can you please give the suggestion a try?

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Anatol
Top achievements
Rank 1
answered on 09 Jan 2018, 03:53 AM
Thanks for reply!i set to true this property, but it works only for one letter, if i type a second letter in "full text search" it returns empty result. For example: i search word "hello", i type letter "h" and it returns to me search result "Hello" and than if i add "e" it returns empty result.
0
Stefan
Telerik team
answered on 11 Jan 2018, 12:04 PM
Hi Anatol,

I performed some testing of the searching mechanism and was not able to replicate such malfunction. Attached to my reply you can find a short video demonstrating this. Am I missing something? If you are using the control in the same manner, can you please clarify what assemblies version are you using?

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Anatol
Top achievements
Rank 1
answered on 11 Jan 2018, 02:56 PM

Thanks for reply!

I use Telerik.2017.R2/Telerik_UI_for_WPF_2017_2_503_Dev. VS 2017 .net 4.0.

I attached my video demonstrating.

Regards,
Anatol 

0
Stefan
Telerik team
answered on 16 Jan 2018, 12:56 PM
Hello Anatol,

I tested the 2017.2.503 assemblies and the searching is again working as expected on my end. My best guess for the behavior you are experiencing is that it might be due to the implementation of the Equals and GetHashCode methods. You can easily verify this by testing the search mechanism without overriding these methods. Can you please give it a try?

Best Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Anatol
Top achievements
Rank 1
answered on 17 Jan 2018, 02:39 AM

Hello!

I ve tried it without overriding gethashcode and equals, but it does n't work again...

0
Stefan
Telerik team
answered on 19 Jan 2018, 03:15 PM
Hi Anatol,

Sorry to hear that you are still experiencing this issue with the text search mechanism.

Though I cannot reproduce it on my end, I can suggest you updating to our latest R1 2018 release. Recently, we made a couple of fixes regarding the search functionality that might be related to behavior you are experiencing as well.

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Josh
Top achievements
Rank 1
answered on 21 Feb 2018, 07:51 PM

I cannot seem to get the full text searching working for ColumnBox columns or number column.  It works ONLY for string columns.

How can we get this working for ALL columns?

 

0
Stefan
Telerik team
answered on 26 Feb 2018, 01:42 PM
Hello Josh,

As discussed in this thread, in order the search mechanism to be able to work with a GridViewComboBoxColumn, the IsLightweightModeEnabled property of the column needs to be set to True. Can you please confirm that you have set the property on your end? As to searching over a numeric column, you can observe that the control supports it in the Search as You Type WPF Demo. Can you please take a look at it?

Regards,
Stefan
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
General Discussions
Asked by
Anatol
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Anatol
Top achievements
Rank 1
Josh
Top achievements
Rank 1
Share this question
or