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>