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

Strange GridViewDataColumn not filtrable

2 Answers 69 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dario Concilio
Top achievements
Rank 2
Dario Concilio asked on 22 Apr 2016, 09:01 AM

Hello,

I created a GridView that shows a List<object>, this "object" could be several types, all these types inherit from a same type. This base type has 3 properties:Key, Value and Icon.

Now I show my XAML

<telerik:RadGridView.Columns>
  <telerik:GridViewImageColumn Header="" DataMemberBinding="{Binding Icon,Converter={StaticResource IconaParametroConverter}}"     IsFilterable="False"/>
  <telerik:GridViewDataColumn Header="Parametro" DataMemberBinding="{Binding Caption}" Width="Auto"/>
  <telerik:GridViewDataColumn Header="Valore" DataMemberBinding="{Binding Value,Converter={StaticResource DynamicsParameterConverter}}" Width="*" CellStyle="{StaticResource ValueBoldStyle}" />
</telerik:RadGridView.Columns>

I attached what it shows at runtime.

The ValueColumn has not the filter control.

The only things is that DataMemberBinding has connected with a Converter because Value property should be several type, but this converter return ever string.

Is it for this reason that not appear a filter control?

This is a converter code (Column of value is not editable)

public class DynamicsParameterConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter,
      System.Globalization.CultureInfo culture)
    {
        if (value == null)
            return "";
 
        if (value.GetType() == typeof(DateTime))
        {
            var date = (DateTime) value;
            return date.ToShortDateString();
        }
        else if (value.GetType() == typeof(int))
        {
            var number = (int) value;
            return number.ToString();
        }
        else if (value.GetType() == typeof(bool))
        {
            var siNo = (bool) value;
            return siNo ? "Sì" : "No";
        }
        else if (value.GetType() == typeof(double))
        {
            var valore = (double) value;
            return string.Format("{0:N2}", valore);
        }
        else if (value.GetType() ==typeof(CausaleIVA))
        {
            var valore = (CausaleIVA) value;
            return string.Format("{0} ({1})", valore.Codice, valore.Descrizione);
        }
        else
            return value.ToString();
    }
    //....
}

 

 

2 Answers, 1 is accepted

Sort by
0
Dario Concilio
Top achievements
Rank 2
answered on 22 Apr 2016, 09:02 AM

ERRATA CORRIDGE:

The property Value is not in a base class.

 

0
Accepted
Yoan
Telerik team
answered on 26 Apr 2016, 02:11 PM
Hi,

I would suggest you to check the Why doesn’t my column show the filtering funnel icon? help article for a reference. Please keep in mind that our filtering mechanism is working with the underlying data, so you will not be able to filter the converted value.

Regards,
Yoan
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Dario Concilio
Top achievements
Rank 2
Answers by
Dario Concilio
Top achievements
Rank 2
Yoan
Telerik team
Share this question
or