Skip to content

Replies

0
Alex McMahon
Alex McMahon answered on Nov 17, 2008 1:44 PM

 Not a bad workaround! So the key is de-activating and re-activating the cell to force a refresh. probably a bit tidier than my way, as it's more focussed on the individual situation where the problem occurs. I'll store your method in the old brain box in case we need this functionality again!

0
Alex McMahon
Alex McMahon answered on Nov 17, 2008 11:32 AM

Alex,

This is the code I used. We've actually stopped doing this now as it's a bit of a workaround. What we now do is pre-populate the drop-down with all possible values (even if they're not currently displayed), so it never needs to update. This worked well for us as the list of possible values was based on an enum so was fixed.

 

       if (grid.Rows.FilterRow != null & grid.Rows.FilterRow.Cells != null)
      {
        foreach (UltraGridFilterCell cell in grid.Rows.FilterRow.Cells)
        {
          ValueList values = cell.ValueListResolved as ValueList;
          if (values != null)
          {
            values.ValueListItems.Clear();
          }
        }
      }

Hope that helps

0
Alex McMahon
Alex McMahon answered on Sep 25, 2008 1:18 PM

 Just to update the thread with the resolution. The issue was responded to by eventually being marked as "not a bug" with completely understandable reasoning. Something in the response made me think of a workaround:

“This is correct
behavior since we don't want to populate and re-populate the filter
list every time it is dropped down, since this would be very
inefficient for the vast majority of users. The Filter Cell
specifically checks the count of the items in the ValueList when you
drop it down. When you enter edit mode on the filter cell and drop down
the list, it's empty, so it populates it and fires the
BeforeRowFilterDropDownPopulate and BeforeRowFilterDropDown events. The
second time you drop it down while it is still in edit mode, the count
is greater than 0 and it deliberately does not fire the events of
re-populate list. If it did, this would be very inefficient for the
vast majority of customers whose values are not going to change while
the filter cell is in the middle of being edited by a user.”

 

My Workaround:

When I update the data source I also iterate through the filter row in
the grid clearing out all the valuelists so that all the dropdowns will
be forced to refresh.

0
Alex McMahon
Alex McMahon answered on Sep 22, 2008 3:56 PM

Thanks for the suggestion.I wasn't handling those events before, but adding a handler showed me something interesting. The events were only being triggered on the first expansion of the dropdown (until the dropdown lost focus again). I've updated to the latest version with hotfixes and have seen same behaviour. I've now created a simplified demo app that I've sent to Developer Support (CAS-06045-Z66K79).  

 I think what I'm after is either for the dropdown to repopulate every single time, or for a way to invalidate the dropdown's valuelist so that it is re-populated next time.

0
Alex McMahon
Alex McMahon answered on Sep 19, 2008 2:55 PM

 I am seeing the actual rows in the grid update, so I assume that the data source must be notifying the grid of changes. The data source is a System.Windows.Forms.BindingSource, that uses a    System.ComponentModel.BindingList<TItem> as it's DataSource, the BindingList is initialized from a List<TItem>. (Hope that chain made sense!). Then when one of the TItems is updated we replace the instance in the BindingSource with the new version. I didn't originally create this code… Does it look right to you? is there a 'better' way?

Simplified versions of the 2 relevant methods are below.

public

void PopulateGrid(List<TItem> itemList)
{
BindingList<TItem> boundList = new BindingList<TItem>(itemList);
gridBindingSource.DataSource = boundList;//This is of type BindingSource
grid.DataSource = gridBindingSource;
} 

public

 void AddOrUpdateItem(TItem item)
{
int idx;
if ((idx = gridBindingSource.IndexOf(item)) != -1)
{
//the item already exists in the list so replace it
gridBindingSource[idx] = item;
}
else
{
//add the new item
idx = gridBindingSource.Add(item);
}
}

0
Alex McMahon
Alex McMahon answered on Sep 19, 2008 8:59 AM

Mike, 

Thanks for the reply. 

Now that's interesting. Where is the list repopulated from? As it's definately not being populated with the right values.

 I don't mean while it's already open. I'm seeing the wrong values when I open the drop-down. Interestingly enough if I resize the column and then do the drop-down it updates to reflect the new values. Or if I click on a row in the grid first and then on the drop down it also updates. The grid is read-only and it's when the data it's bound to changes that the drop-down is not updated.

 I'll have a look at how we're doing the binding, perhaps we're doing something slightly odd.