Filter icon not appearing

5 posts, 1 answers
  1. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 22 May 2012 Link to this post

    Hi,
    I want to use the built in filters for the grid, but the icon does not appear

    This is my XAML code
    <telerik:RadTreeListView x:Name="grid" Grid.Row="2" AutoGenerateColumns="False" RowLoaded="grid_RowLoaded" IsFilteringAllowed="True"
                                     RowIsExpandedChanged="grid_RowIsExpandedChanged" RowIsExpandedChanging="grid_RowIsExpandedChanging" SelectionChanged="grid_SelectionChanged" CellEditEnded="grid_CellEditEnded">
                <telerik:RadTreeListView.ChildTableDefinitions>
                    <telerik:TreeListViewTableDefinition ItemsSource="{Binding Path=Children}" />
                </telerik:RadTreeListView.ChildTableDefinitions>
            </telerik:RadTreeListView>

    And I create the Columns in code behind, I are there any properties I need to enable ?
    When I have tried to set the IsFilterable = true in the code behind where I create the columns.

    And I am using Telerik Dll's V.2012.1.326.40

    Thank you
    Kristján


  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 22 May 2012 Link to this post

    Hello,

    Basically, the column will not have filtering option if the type of the property that is bound to this column is not known.  Would you please share more details on what your data is?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 22 May 2012 Link to this post

    The data is dynamic and I don't know how may columns there will be.

    But this is the ItemsSource is a list of this object ->
    public class DataClass
        {
            public List<Mycolumns> Values { get; set; }
            public List<DataClass> Children { get; set; }
            public DataClass Parent { get; set; }
            public bool HasChildren { get; set; }
            public int LevelID { get; set; }
     
            public DataClass()
            {
                Values   = new List<Mycolumns>();
                Children = new List<DataClass>();
            }
     
            public DataClass(DataClass parent)
            {
                Values   = new List<Mycolumns>();
                Children = new List<DataClass>();
                Parent   = parent;
            }
        }

    This is the Mycolumns object
    public class Mycolumns
        {
            public object ColName { get; set; }
            public object Value { get; set; }
            public Type DataType { get; set; }
        }

    And here is how I create the columns
    List<DataClass> data = dhelper.getDataForLevel(0, "", "");
                    for (int i = 0; i < data.First().Values.Count; i++)
                    {
                        grid.Columns.Add(createColumn("Values[" + i + "].Value", data.First().Values[i].ColName.ToString(), data.First().Values[i].DataType));
                    }
                    grid.ItemsSource = data;

    //and this is the createColumn method
    private GridViewDataColumn createColumn(string bindingText, string caption, Type dataType, string tag = "", string toolTip = "")
            {
                GridViewDataColumn col = new GridViewDataColumn();
                col.HeaderTextAlignment = TextAlignment.Right;
                if (dataType == typeof(double))
                {
                    col.DataFormatString = "{0:N0}";
                }
                else if(dataType == typeof(DateTime))
                {
                    col.DataFormatString = "{0:d}";
                }

                col.TextAlignment = TextAlignment.Right;
                col.Header = caption;
                col.Tag = tag;

                col.IsReadOnly = (!caption.Equals("UnitQtyChg")) ? true : false;
                col.DataMemberBinding = new Binding(bindingText) { Mode = BindingMode.TwoWay };

          return col;
            }

    Hope this clears anything up

    Best regards
    kristján


     
  5. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 24 May 2012 Link to this post

    Hi Kristján,

     When the column filters on a certain property, this property has to be filterable. When the property is of type object, then the RadGridView does not know how to filter.

    Probably this blog post can help you implement your filtering. 

    All the best,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Kristjan Einarsson
    Kristjan Einarsson avatar
    95 posts
    Member since:
    Jan 2010

    Posted 25 May 2012 Link to this post

    Thank you, I got this working by using col.DataType = myDataType;
    Works like a charm
Back to Top
UI for WPF is Visual Studio 2017 Ready