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

2009 Q1: Breaking change on update events?

9 Answers 190 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tomas
Top achievements
Rank 1
Tomas asked on 16 Mar 2009, 03:18 PM
Hi!

After upgrading to the latest release, I no longer receive updates after cells/rows have been edited.

I have attached a small example which I believe would work under last version (can't verify this since I have uninstalled it) but not under Q1.

Is there another way to hook up the events, or some other way to detect changes?

Thanks!

<Window x:Class="GraphTest.Window2" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Title="Window2" Height="300" Width="300" Loaded="Window_Loaded">  
    <Grid> 
        <telerik:RadGridView  AutoGenerateColumns="True" telerik:GridViewCell.EditEnded="gridview_EditEnded" telerik:GridViewRow.EditEnded="gridview_RowEditEnded" x:Name="gridview"  Grid.Column="0" Grid.Row="0" > 
        </telerik:RadGridView> 
    </Grid> 
</Window> 
 
using System.Windows;  
using System.Collections.ObjectModel;  
 
namespace GraphTest  
{  
    /// <summary>  
    /// Interaction logic for Window2.xaml  
    /// </summary>  
    ///   
 
    public partial class Window2 : Window  
    {  
        public Window2()  
        {  
            InitializeComponent();  
        }  
 
 
        private void Window_Loaded(object sender, RoutedEventArgs e)  
        {  
            gridview.ItemsSource = new TestList();  
        }  
 
        private void gridview_RowEditEnded(object sender, Telerik.Windows.Controls.GridView.Rows.RecordRoutedEventArgs e)  
        {  
            // Never gets called  
            MessageBox.Show("Row edit");  
        }  
 
        private void gridview_EditEnded(object sender, Telerik.Windows.Controls.GridView.Cells.CellRoutedEventArgs e)  
        {  
            // Never gets called  
            MessageBox.Show("Cell edit");  
        }  
 
    }  
 
    public class TestDataEntry  
    {  
        public int id { getset; }  
        public string value { getset; }  
    }  
 
    public class TestList : ObservableCollection<TestDataEntry>  
    {  
        public TestList()  
        {  
 
            Add(new TestDataEntry() { id = 1, value = "something" });  
            Add(new TestDataEntry() { id = 2, value = "something else" });  
        }  
 
    }  
}  
 


9 Answers, 1 is accepted

Sort by
0
Accepted
Missing User
answered on 16 Mar 2009, 04:54 PM
Hi Tomas,

There are some breaking changes to editing logic. GridViewRow.EditEndedEvent is replaced with GridViewDataControl.RowEditEndedEvent and GridViewCell.EditEndedEvent is replaced with GridViewDataControl.CellEditEndedEvent.

Your code should look like this:
this.gridview.AddHandler(GridViewDataControl.RowEditEndedEvent, new EventHandler<GridViewRowEditEndedEventArgs>(this.OnRowEditEnded));  
 
this.gridview.AddHandler(GridViewDataControl.CellEditEndedEvent, new EventHandler<GridViewCellEditEndedEventArgs>(this.gridview_EditEnded));  
 
 
 private void OnRowEditEnded(object sender, GridViewRowEditEndedEventArgs e)    
        {    
   
        }  
 
  private void gridview_EditEnded(object sender, GridViewCellEditEndedEventArgs e)  
        {    
 
        }   

Sorry for the inconvenience caused.

Having other questions - do not hesitate to contact us again.

Kind regards,

Anastasia
the Telerik team



Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 17 Mar 2009, 12:24 AM
Hi,

I tried to set this in markup like this:
        <telerik:RadGridView AutoGenerateColumns="True" Height="200" HorizontalAlignment="Right" Margin="0,0,0,0" Name="radGridView1" telerik:GridViewDataControl.RowEditEnded="radGridView1_RowEditEnded">  
        </telerik:RadGridView> 
 
The result:
Fehler  1   Die Eigenschaft "GridViewDataControl.RowEditEnded" ist im XML-Namespace "http://schemas.telerik.com/2008/xaml/presentation" nicht vorhanden.  
In english - the property ...RowEditEnded does not exit in the namespace....
I ended up in
radGridView1.AddHandler(GridViewDataControl.RowEditEndedEvent, new EventHandler<GridViewRowEditEndedEventArgs>(radGridView1_RowEditEnded)); 
Bad to write such a thing - everything mus be typed - intellisense does not even generate a handler....
But - and that's really the hard thing (I suspected from snoop - where I searched events) -- the event does not fire!!!

The only event I get (via snoop) is "cell edit ending".

How to solve this?

Manfred
0
Tomas
Top achievements
Rank 1
answered on 17 Mar 2009, 08:23 AM
Thanks, Anastasia.

I also only receive events for cells and not rows, but that is ok.

I had to rewrite the handler a bit, so this should probably be documented. For reference, these are my old and new handlers.

old handler
        private void gridview_EditEnded(object sender, Telerik.Windows.Controls.GridView.Rows.RecordRoutedEventArgs e)  
        {  
            DataRecord r = (DataRecord)e.Record;  
            SomeRecordType record = (SomeRecordType)r.Data;  
 
        }  
 
new handler

        private void gridview_EditEnded(object sender, GridViewCellEditEndedEventArgs e)  
        {  
            SomeRecordType record = (SomeRecordType)e.Cell.DataContext;             
        } 
0
ManniAT
Top achievements
Rank 2
answered on 17 Mar 2009, 12:28 PM
Hi Thomas,

yes it is not a problem to change the handler.
Since I have a datacontext my code wouldn't even change - it would just appear on a different place.
myContext.SaveChanges() or myOtherContext.SubmitChanges() would be in the cell instead of the row handler.

BUT - and that's the real problem - behind the scenes I call services and they write into an audited database server.
If the user changes 10 of 30 fields in a record this would mean with rows:
1 Service Call / 1 Audit Entry
With the "new approach" it would mean
10 Service Calls / 10 Audit Entries.

Or in other words - 10 Times more transactions...
With a few thousands clients this really affects the DB performance.

The next problem (just as a sample) - we have two prices in out table - prime cost and retail price.
Retail must never be lower than prime -- so I have to force the user to first change prime and after it retail.
Else (if price lowers) the retail price could be below prime....

So my app relays on handling (validation / store and so forth) a row - not a cell.
I know I could handle these things somehow (checking selected row index or something else) but thats against the concept why I bought a third party control - I wanted to safe development time - and not to have a thing where I must add extra effort to get it running.

Anyhow - it is somehow documented - so this can not be a "normal behavior" - instead it seems to be a bug.

Regards

Manfred
0
Pavel Pavlov
Telerik team
answered on 19 Mar 2009, 11:33 AM
Hi ,
I have prepared for you a sample illustrating Row by Row editing (data is submitted after editing entire row).

Please have a look at the attached project.


Greetings,
Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
ManniAT
Top achievements
Rank 2
answered on 19 Mar 2009, 02:00 PM
Hi Pavel,

thanks for the information and the attached sample.
I simply would say this line of code
this.RadGridView1.ValidationMode = ValidationMode.Row;//This is important! Without this OnRowEditEnded will not fire.  
 
does the trick.

So it's not a bug - it's just a behavior that changed with the new version and the thing is missing in documentation.
I guess this should be "extra highlighted" and reference.
 What I mean is - if I look at the RowEditEnded event there should be a note "CAUTION: event fires only when..."

Regards

Manfred
0
Doug Lott
Top achievements
Rank 1
answered on 26 Mar 2009, 05:36 PM
Thanks Manfred!  I was lost without that one.  Let's hope Telerik's documentation catches up to their software releases soon.
0
branko
Top achievements
Rank 1
answered on 07 May 2009, 08:34 AM
I have a feature proposal regarding ValidationMode property... What about ValidationMode="CellAndRow"? 

This would allow us to validate, for example, birth date (if it is greater than 1900) with cell validation and then validate row (if date of first employment is after birth date)...

And what about IDataErorrInfo validation support? :)

Regards.
Branko
0
Nedyalko Nikolov
Telerik team
answered on 07 May 2009, 01:21 PM
Hello branko,

Thank you for your feedback.
This indeed is a good idea and we will consider introducing such Validation scenario.
I think that support for IDataErrorInfo will come naturally with implementation of the ValidationMode.CellAndRow. I cannot commit with any specific date or release, but there are some plans for improving editing mechanism and related keyboard navigation.

Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Tomas
Top achievements
Rank 1
Answers by
Missing User
ManniAT
Top achievements
Rank 2
Tomas
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Doug Lott
Top achievements
Rank 1
branko
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or