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

Excel-Like Editing

1 Answer 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Scott Michetti
Top achievements
Rank 1
Scott Michetti asked on 09 Jan 2014, 07:53 PM
Hello, I'm trying to get the grid editing to behave like Excel. I've seen numerous posts on this, but some are a few years old, so I'm wondering if it is supported now. I'm setting the following grid properties to get close to what I want:
radGrid.SelectionUnit = GridViewSelectionUnit.Cell;
radGrid.EditTriggers = GridViewEditTriggers.TextInput | GridViewEditTriggers.CurrentCellClick;
 radGrid.SelectionMode = SelectionMode.Extended;

Specifically, I'm looking for the following behavior:

1. Select a cell. Start typing and the cell goes into edit mode. This works.
2. Select a cell. Single click the cell again causes the cell to go into edit. I would like the cell to go into edit mode on a double click, like Excel. Also, this causes a selection problem as well because if I mouse down in the already selected cell to do a multiple cell selection, I can't because the cell goes into edit. This is actually my biggest issue.
3. Press Enter key after edit causes the next cell to go into edit mode. I would like Enter to just move to the next cell without editing. This goes for the Tab key, and click another cell in the same row(clicking a cell in another row will not place that cell into edit mode). All place you into edit mode. Excel does not do this and this is the behavior I would like.

If there's a way to set properties to get the functionality I'm looking for, that would be great. Otherwise, any suggestions?
This post http://www.telerik.com/community/forums/wpf/gridview/cell-edit-mode.aspx discusses overriding the keyboard command provider. Is that what is recommended? It seems like editing like Excel would be functionality that should be built into the grid control.

Thanks,
Scott



1 Answer, 1 is accepted

Sort by
0
Vera
Telerik team
answered on 13 Jan 2014, 01:05 PM
Hello Scott,

Straight to your questions:

2. In order to achieve the cell editing functionality, you can set RadGridView.EditTriggers property to TextInput only and use the following logic in MouseDoubleClick event:

void MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            FrameworkElement originalSender = e.OriginalSource as FrameworkElement;
            if (originalSender != null)
            {
                var cell = originalSender.ParentOfType<GridViewCell>();
                if (cell != null)
                {
                    cell.BeginEdit();
                }
            }
        }

As for the range selection, you will not be able to select multiple cells by dragging from an already selected cell with the built-in functionality. Unfortunately, this is the expected behavior since RadGridView first checks whether the start cell is selected and, in case it is not, selects the range of cells. Any different behavior would be a breaking change. The only way to overcome the limitation is to set the DragElementAction to None, and implement the range selection on your own in a separate behavior using the Mouse events.

3. You can use a custom keyboard command provider. Please check the attached project and this help article for more information.

I hope this helps.

Regards,
Vera
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Scott Michetti
Top achievements
Rank 1
Answers by
Vera
Telerik team
Share this question
or