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

[Solved] How manually update a cell text?

3 Answers 137 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Wyller
Top achievements
Rank 1
Wyller asked on 29 Oct 2010, 01:46 PM
Hi,

I'm using a RadGridView binded to an ObservableCollection<x> with 4 properties.
I manually created 4 columns on the RadGridView, 2 are of type GridViewColumn and the other 2 are GridViewDataColumn binded datasource properties.

How can I manually change the values for the 2 GridViewColumn without updating/redrawing the entire RadGridView?

Thanks!

3 Answers, 1 is accepted

Sort by
0
Yavor Georgiev
Telerik team
answered on 29 Oct 2010, 01:49 PM
Hello Wyller,

 Does your data class implement INotifyPropertyChanged? The RadGridView should update the relevant cell automatically if your data item is INotifyPropertyChanged.

Regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Wyller
Top achievements
Rank 1
answered on 29 Oct 2010, 03:03 PM
Hi, it's still not working, here's how I'm doing this.

Here's my RadGridView:

 

<telerik:RadGridView telerik:StyleManager.Theme="Windows7" HorizontalAlignment="Left" Margin="12,368,0,0" Name="gvLegenda" VerticalAlignment="Top" Width="975" Height="201" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" CanUserFreezeColumns="False" CanUserDeleteRows="False" CanUserInsertRows="False" CanUserSelect="False" IsFilteringAllowed="False" IsEnabled="False" ShowGroupPanel="False" DataLoadMode="Synchronous" EnableColumnVirtualization="True" EnableRowVirtualization="True" SelectionMode="Single" IsReadOnly="False" RowIndicatorVisibility="Collapsed">
    <telerik:RadGridView.Columns>
        <telerik:GridViewColumn MaxWidth="40" MinWidth="40" Width="40" IsGroupable="False" />
        <telerik:GridViewDataColumn Header="Coluna" MinWidth="250" IsGroupable="False" DataMemberBinding="{Binding ColumnName}" />
        <telerik:GridViewDataColumn Header="Função" MinWidth="300" IsGroupable="False" DataMemberBinding="{Binding Function}"/>
        <telerik:GridViewDataColumn Header="Valor" MinWidth="80" IsGroupable="False" DataMemberBinding="{Binding CurrentCursorValue}" />
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

Here my class:

public class POPLegend : INotifyPropertyChanged
 {
     public GraphData.Color SerieColor { get; set; }
     public string ColumnName { get; set; }
     public string Function { get; set; }
     public double CurrentCursorValue { get; set; }

     public event PropertyChangedEventHandler PropertyChanged;
 }

I'm binding like this:
var lstLegend = new ObservableCollection<POPLegend>();
             
           for (int x = 0; x < e.Result.Count - 1; x++)
           {
               lstLegend.Add(new POPLegend { SerieColor = e.Result[x].SerieColork__BackingField, ColumnName = e.Result[x].Namek__BackingField });
               radChart1.SeriesMappings.Add(seriesMapping);
           }
           gvLegenda.ItemsSource = lstLegend;

Thanks!
0
Wyller
Top achievements
Rank 1
answered on 29 Oct 2010, 05:20 PM
I was using the INotifyPropertyChanged in a wrong way. Bellow is the correct way.

public double CurrentCursorValue
  
{
  
get { return _CurrentCursorValue; }
  
set
  
{
  
if ((object.ReferenceEquals(_CurrentCursorValue, value) != true))
  
{
  
_CurrentCursorValue = value;
  
RaisePropertyChanged("CurrentCursorValue");
  
}
  
}
  
} private double _CurrentCursorValue;
  
 public event PropertyChangedEventHandler PropertyChanged;
  
        protected void RaisePropertyChanged(string propertyName)
        {
            PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
            if ((propertyChanged != null))
            {
                propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
            }
        }
Tags
GridView
Asked by
Wyller
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
Wyller
Top achievements
Rank 1
Share this question
or