Strange GridViewDataColumn not filtrable

3 posts, 1 answers
  1. Dario Concilio
    Dario Concilio avatar
    129 posts
    Member since:
    Apr 2016

    Posted 22 Apr Link to this post

    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. Dario Concilio
    Dario Concilio avatar
    129 posts
    Member since:
    Apr 2016

    Posted 22 Apr in reply to Dario Concilio Link to this post

    ERRATA CORRIDGE:

    The property Value is not in a base class.

     

  3. UI for WPF is Visual Studio 2017 Ready
  4. Answer
    Yoan
    Admin
    Yoan avatar
    1070 posts

    Posted 26 Apr Link to this post

    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.
Back to Top