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

Filter icon not appearing

4 Answers 104 Views
TreeListView
This is a migrated thread and some comments may be shown as answers.
Kristjan Einarsson
Top achievements
Rank 1
Kristjan Einarsson asked on 22 May 2012, 11:26 AM
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


4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 22 May 2012, 01:03 PM
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 >>

0
Kristjan Einarsson
Top achievements
Rank 1
answered on 22 May 2012, 02:12 PM
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


 
0
Accepted
Dimitrina
Telerik team
answered on 24 May 2012, 12:01 PM
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 >>

0
Kristjan Einarsson
Top achievements
Rank 1
answered on 25 May 2012, 10:58 AM
Thank you, I got this working by using col.DataType = myDataType;
Works like a charm
Tags
TreeListView
Asked by
Kristjan Einarsson
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Kristjan Einarsson
Top achievements
Rank 1
Share this question
or