Ticket T318936
Visible to All Users

Updating datasource data doesn't update filtered view

created 9 years ago (modified 9 years ago)

I have a Grid Control , and bound to a BindingList

I have pro gramminly applied filter on the GridView by setting the ActionFilterString.

gridView1.ActiveFilterString = "[Hidden] = false";

I works and only show objects that have .Hidden = false;

And then I tried to un-hide all hidden items in the View:

var hiddenOrders = listDataSource.Where(x => x.Hidden == true);
foreach(Order o in hiddenOrders)
     o.Hidden = false;

However the Grid does not update.

What is the problem?

Thanks.

Answers approved by DevExpress Support

created 9 years ago (modified 9 years ago)

Hello,
It is likely that the GridControl doesn't receive notifications from the BindingList. You can check it by handling the BindingList.ListChanged event. This event is not raised when you change the Hidden property.
Implement the INotifyPropertyChanged interface for the Order class. This way, the ListChanged event will be raised and GridControl will be updated after executing your code.
I hope you find this information useful.

    Comments (2)

      I follow the MVVM documents and inherited BindableBase in Order class.
      Use SetProperty in the Hidden field. Now I can update the Grid when value change.
      I have another question. In the MVVM documentation. It have example to use ObservableCollection<T>
      If I use ObserverableCollection<Order> as the binding source, when I update one of item in the collection, do the grid receive update notification? I tried it doesn't. Don't know if I miss sth.
      Btw. In the document https://documentation.devexpress.com/#WindowsForms/CustomDocument113956, the SetProperty have typo , it throw compile error
      set { SetProperty(ref titleValue, "Title");}
      It should be :
      set { SetProperty(ref titleValue, value, "Title");}

      Sasha (DevExpress Support) 9 years ago

        Hello Jason,
        The ObservableCollection class does not implement the IBindingList interface. So, the grid can't get notifications about its changes. I suggest that you use BindingList  instead. This way, the Grid should be updated correctly.
        Attached is a small sample that demonstrates this approach.

        Btw. In the document  https://documentation.devexpress.com/#WindowsForms/CustomDocument113956, the SetProperty have typo , it throw compile error
        Thanks for pointing out this error. I created a separate thread on your behalf: Documentation - Correct the mistake in the Data Bindings and Notifications article. We will update that thread as soon as we correct our documentation.

        Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

        Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.