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

Scrolling cells in edit mode

4 Answers 33 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 21 Jul 2011, 03:48 AM
I have a gridview where I edit a number of cells.

Issue 1
If in the validating code I set the cells back color it is not stable, when scrolling the highlighted cell can change, if I scroll an entire page the highlighted cell will repeat on subsequent cells.
e.Cell.Foreground = new SolidColorBrush(Colors.Red);
I fixed this by using the cellstyleselector and basing the change on data in the underlying object. It is still a fault of the gridview.

Issue 2 - unsolved
If I scroll rapidly when in edit mode (the user holds down the arrow key) the values in the cells are set to 0. I believe this may be the fault of the validating code and the speed of the scroll. If the user presses esc twice after editing the cell the grid is no longer in edit mode and the data is secure. Is there a way to place the grid out of edit mode from the cellendedit event
private void lPCellEditEnd(GridViewCellEditEndedEventArgs e)
        {
            decimal OriginalValue;
            decimal CurrentValue;
            decimal.TryParse(e.OldData.ToString(), out OriginalValue);
            decimal.TryParse(e.NewData.ToString(), out CurrentValue);
            LPItemEditDB oLPEdit = e.Cell.DataContext as LPItemEditDB;
 
 
            if (CurrentValue != OriginalValue)
            {
                CurrentValue = DecimalTruncated(CurrentValue);
                LPItemDB oLPItem = GetEditableLP(e.Cell.Column.UniqueName, oLPEdit, CurrentValue, OriginalValue);
                //e.Cell.Foreground = new SolidColorBrush(Colors.Red);
                CalcTotal(oLPEdit);
            }
        }

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 21 Jul 2011, 12:06 PM
Hello Mark,

Basically, the RadGridView is virtualized by default (its EnableColumnVirtualization and EnableRowVirtualization properties are set to "True"). Consequently, the visual elements are recreated and reused on scrolling. So, if you set a property directly to a cell for example, it will probably applied to other cells on scrolling. If you turn off the virtualization, you will not get this behavior, but this may lead to degraded performance. Still, the recommended approach is to use a CellStyleSelector.
Considering your second issue, I have tried to reproduce it, but unfortunately without any success. Generally, if a cell is in edit mode and the Down arrow key is pressed, the cells below get into edit mode as well. Is that your scenario ? Is this applicable to all your columns ? How do you define them ? If the CellEditEnded event is not handled, do you get the same behavior ? 
 

Greetings,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Mark
Top achievements
Rank 1
answered on 22 Jul 2011, 01:30 AM
Changing to cellstyleselector fixed the first issue nicely.

The second issue seems to be associated with the amount of work done in the editend event.
First we placed a busyindicator around the event, this slowed down the scroll movement but did not fix the problem of zeroing the data.
We then we trapped the comparison of the change, testing the old value and the new value - no change

Is there any way to place the grid in a non edit mode, this can be done by the user pressing esc twice after the edit. I would like to do this programatically after the endedit event!
0
Maya
Telerik team
answered on 27 Jul 2011, 12:42 PM
Hello Mark,

Basically, once the cell loses focus, it gets out of edit mode and the CellEditEnded event is fired. There is no need to do anything more specific. Double pressing the Esc key cancels the edit - is that what you are looking for ? Why do you need to use a busy indicator in this event ? May you clarify what is the general scenario that you want to accomplish in the CellEditEnded event ? If possible, may you try to send us a small sample project illustrating the issue ? 
 

Kind regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Mark
Top achievements
Rank 1
answered on 01 Sep 2011, 08:33 AM
RESOLVED

This issue was resolved by trapping the e.CurrentValue and testing for an empty string. When the user holds the arrow key down in edit mode e.CurrentValue is an empty string. This string failed validation causing the values to be set to zero.
Tags
GridView
Asked by
Mark
Top achievements
Rank 1
Answers by
Maya
Telerik team
Mark
Top achievements
Rank 1
Share this question
or