Menu

#18 Duplicate items when setting ModelFilter

v2.X
open
None
1
2018-12-19
2018-12-19
Paul. F
No

Hi Phillip, I found a possible issue, I have a list of objects which display fine on the grid, if I apply a model filter to the grid then a few items on the grid will appear twice, if I check the list size I can confirm that it contains the correct amount of items, but more items get rendered on the grid, if I remove the ModelFilter the grid keeps displaying double items.

Here's how I set the filter:

lstTasks.ModelFilter = new ModelFilter(delegate (object modelObject)
            {
                return VisibleObjectIds.Contains(((TaskObject)modelObject).Id);
            });

and how I clear it:

lnkClearFilter.Hide();

            lstTasks.ModelFilter = new ModelFilter(delegate (object modelObject)
            {
                return true;
            });

When I load the list initially it is perfect, the duplicates will appear only after appying a filter and won't go away after clearing it.

Thank you

Related

Support Requests: #18

Discussion

  • Paul. F

    Paul. F - 2018-12-19

    In fact any filter duplicates some of the items, like this:

    public class TestFilter : IModelFilter
            {
                public bool Filter(object modelObject)
                {
                    return true;
                }
            }
    
     
    • Phillip Piper

      Phillip Piper - 2018-12-19

      What type of ObjectListView are you using?

      On Thu., 20 Dec. 2018, 4:01 am Paul. F <paul-f@users.sourceforge.net wrote:

      In fact any filter duplicates some of the items, like this:

      public class TestFilter : IModelFilter
      {
      public bool Filter(object modelObject)
      {
      return true;
      }
      }


      Status: open
      Group: v2.X
      Created: Wed Dec 19, 2018 04:27 PM UTC by Paul. F
      Last Updated: Wed Dec 19, 2018 04:27 PM UTC
      Owner: Phillip Piper

      Hi Phillip, I found a possible issue, I have a list of objects which
      display fine on the grid, if I apply a model filter to the grid then a few
      items on the grid will appear twice, if I check the list size I can confirm
      that it contains the correct amount of items, but more items get rendered
      on the grid, if I remove the ModelFilter the grid keeps displaying double
      items.

      Here's how I set the filter:

      lstTasks.ModelFilter = new ModelFilter(delegate (object modelObject)
      {
      return VisibleObjectIds.Contains(((TaskObject)modelObject).Id);
      });

      and how I clear it:

      lnkClearFilter.Hide();

              lstTasks.ModelFilter = new ModelFilter(delegate (object modelObject)
              {
                  return true;
              });
      

      When I load the list initially it is perfect, the duplicates will appear
      only after appying a filter and won't go away after clearing it.

      Thank you

      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/objectlistview/support-requests/18/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Support Requests: #18

  • Paul. F

    Paul. F - 2018-12-19

    Hi Phillip, it's C# Winforms, I could confirm that applying just about any filter to the model filter will make some duplicate items appear while the collection size remains the same.

    public class TestFilter : IModelFilter
            {
                public bool Filter(object modelObject)
                {
                    return true;
                }
            }
    
    private void btApplyModelFilter_Click(object sender, EventArgs e)
            {
                lstTasks.ModelFilter = new TestFilter();
            }        
    

    My objects are very simple, contained in a List<taskobject>:</taskobject>

    public class TaskObject
    {
        public string Id { get; set; } //This is a guid
        public DateTime Date { get; set; }
        public string Description { get; set; }
    }
    
     
  • Paul. F

    Paul. F - 2018-12-19

    Actually if I setup a clean test project I don't get the same problem so the issue must lie somewhere in my code.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.