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

Refresh Entire Column

2 Answers 32 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 09 Mar 2011, 03:07 PM
Hi,

Is there a way to refresh an entire column (bindings, styles, etc.) without having to raise a PropertyChanged event on each object that the cells of the column are bound to?  I understand the virtual nature of the grid, which is why I'd prefer the grid to handle the refreshing of the visible cells instead of me looping through my entire object collection and raising PropertyChanged events, when only a small subset are even visible.  I've managed to achieve the behavior I want by hiding and then showing the column, but I suspect (would hope) there's a more elegant way.

Thanks,
Terry

2 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 10 Mar 2011, 04:04 PM
Hello Terry,

 Unfortunately, programmatically hiding and showing the column is the only way to refresh the cells only in that particular column. The alternative is to call RadGridView.Items.Refresh(), which is equivalent to the source collection raising CollectionChanged with NotifyCollectionChangedAction.Reset. However, this approach can have unwanted behavior, depending on your scenario.

All the best,
Yavor Georgiev
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
blaise
Top achievements
Rank 1
answered on 06 Apr 2011, 01:48 PM
Thank you for the type, it is a good fix when we are working with async loaded combobox.
With this scenario, if the combobox items source is not loaded when the gridview items are loaded, then the column display names are not painted. Here is essential part of a code snippet I use in order to autogenerate some comboboxes.

var column = new GridViewComboBoxColumn
            {
                DisplayMemberPath = displayname,
                SelectedValueMemberPath = assoc.OtherKey,
                DataMemberBinding = new Binding(assoc.ThisKey),
            };
 
var endedcommand = new DelegateCommand(obj =>
                         {
                           column.IsVisible = false;
                           column.IsVisible = true;
                         }
);
 
column.ItemsSource = sourceprovider.ItemsSource(type, propname, endedcommand);
Tags
GridView
Asked by
Terry Foster
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
blaise
Top achievements
Rank 1
Share this question
or