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

Can you: Cancel a Row Change?

3 Answers 143 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 13 Jul 2010, 05:12 AM
Is it possible to cancel a row change with a grid view?
(If not, can I suggest this)


I have an OpenAccess + RIA, and a DomainDataSource to move data to my front end.

Basically, I've implemented a Ok/Cancel message box to undo changes to records, each time your current item changes
If you hit ok, it will DomainDataSource.UndoChanges()
Otherwise if you hit cancel it will stay on the current record: DataView_CurrentChanging(object sender, CurrentChangingEventArgs e) event.. e.Cancel = true;

Now I have buttons that call movetonext previous first last etc. And they work fine with my ok/cancel message box. However, if I click on my gridview, and change items that way, the DomainDataSource.Data(View).CurrentItem, is what it should be (i.e. if I hit cancel, it won't change)
HOWEVER, the GridViews currently highlighted row, is not the correct row.


Is there a way I can make the GridView's "selectedrow" stay linked to the DataContext's current item?

3 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 15 Jul 2010, 02:05 PM
Hi Alexander Sun,

You can Cancel edit of any row any time before RowEditEnded event (RowValidating and RowValidated events).

RadGridView.CurrentItem should be synchronized with underlying domain data source's current item. You can try to set RadGridView.IsSynchronizedWithCurrentItem.

Could you please send us a sample project which we can debug on our side? (if the problem persists)

Greetings,
Nedyalko Nikolov
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
Alex
Top achievements
Rank 1
answered on 04 Aug 2010, 03:04 AM
The value for RadGridView.IsSynchronizedWithCurrentItem is set to it's default value (true) (At compile time, and run time when the issue occurs)
I can confirm that the Domain Data Sources's item is what it should be (the before change value) but the GridView's SelectedItem is not

(Watch window output)
+        domainDataSource.DataView.CurrentItem    {CashSale : 03720bd4-c3f1-41f7-bed9-0bd472a71503}    object {SunixSilver.Web.Model.CashSale}
        CashSaleList_RadGridView.IsSynchronizedWithCurrentItem    true    bool?
+        CashSaleList_RadGridView.SelectedItem    {CashSale : 540bf4d3-5d83-4027-aed3-0223e3fc47e9}    object {SunixSilver.Web.Model.CashSale}

The row editing is not applicable here, as I'm not modifying the value in the grid (But in some other bound control)





The exact method I'm using the RejectChanges() (not undo as I previously typed, but Reject) is:
void cashSale_DataView_CurrentChanging(object sender, CurrentChangingEventArgs e) {
            if (IgnoreCurrent_Changing) return;
             
            //Note, it is not possible to get the DDS from the Data View
            //Note, the sender is the DataView NOT the dds
            DomainDataSource domainDataSource = cashSale_DomainDataSource;
            if (domainDataSource.HasChanges) {
                if (ViewBase.CheckChanges(domainDataSource)) {
                    domainDataSource.RejectChanges();
                } else {
                    if (e.IsCancelable) e.Cancel = true;
                }
            }
        }

0
Nedyalko Nikolov
Telerik team
answered on 04 Aug 2010, 02:12 PM
Hi Alexander Sun,

Could you send us a sample project that demonstrates the issue, which we can debug on our side?
Could you try with our latest binaries since there are some improvements to currency mechanism?

Sincerely yours,
Nedyalko Nikolov
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
Tags
GridView
Asked by
Alex
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
Alex
Top achievements
Rank 1
Share this question
or