Completed
Last Updated: 23 Jun 2016 08:01 by ADMIN
ADMIN
Dimitar
Created on: 23 Mar 2016 12:53
Category: ListView, CardView and CheckedListBox
Type: Bug Report
0
FIX. RadListView - the custom filtering method is not used when there are groups in the control.
To reproduce:
public RadForm1()
{
    InitializeComponent();
    radListView1.EnableCustomGrouping = true;
    radListView1.EnableFiltering = true;
    radListView1.FilterPredicate = Filter;

    radListView1.ShowGroups = true;
    ListViewDataItemGroup docGroup = new ListViewDataItemGroup("Documents");
    ListViewDataItemGroup diskGroup = new ListViewDataItemGroup("Disks");

    radListView1.Groups.Add(docGroup);
    radListView1.Groups.Add(diskGroup);

    for (int i = 0; i < 100; i++)
    {
        ListViewDataItem item = new ListViewDataItem("g1");
        item.Group = docGroup;
        item.Value = rnd.Next(100);
        this.radListView1.Items.Add(item);

        item = new ListViewDataItem("g2");
        item.Group = diskGroup;
        item.Value = rnd.Next(100);
        this.radListView1.Items.Add(item);
    }
}

private void radButton1_Click(object sender, EventArgs e)
{
    radListView1.FilterDescriptors.Add("Value", Telerik.WinControls.Data.FilterOperator.IsGreaterThan, 50);
}
bool Filter(ListViewDataItem item)
{
    Console.WriteLine(item.Value);
    int value = 0;
    if ((int.TryParse(item.Value.ToString(), out value)))
    {

        return value < 50;
    }
    return true;
}

Workaround:
ListViewGroupedItemsCollection items = docGroup.Items as ListViewGroupedItemsCollection;
var innerList = items.GetType().GetProperty("InnerList", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(items);
var view = ((RadListSource<ListViewDataItem>) innerList).CollectionView;
view.Filter = Filter;

(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments