Posted 17 Sep 2010
Link to this post
Interesting - but I think this distinction is going to be lost with a lot of people.
I would explain it a bit different - Focus and Selection is different - just because a control does not have focus, does not always mean the data is selected. Focus and Selection is often thought of as the same due to the behaviour of the TextBox. For example, highlighting text in a text box means that there is data (ie.the text) selected, and the control (which holds the data) must also then have focus - as the cursor must be in the control in order to highlight the text. If you move away from the control (ie. cursor is moved to another control and the user clicks, or hits the tab key), the control loses focus. If the text control doesn't have focus, it cannot have highlighted text. For the text control, losing focus also means that if data is selected, the control "forgets" what data is selected, but retains the text.
In the grid control - the behaviour of Focus and Selection is different. The control manages collections, and the SelectedRow may be differnent that than the row that is Current (has Focus, or where the cursor is). In most cases however, the CurrentItem is always the SelectedItem, but there are circumstances where this synronization is problematic.
I may be incorrect here - but from your documentation - the CurrentItem in the grid (i.e. where the cursor is setting), may be a row, or a cell - depending on a configurable option as to what the default behaviour should be. It the row current, or is the cell current when the cursor is updating a cell. By default, when a cell is editted, the row is also current, as well as selected.
These are all subleties that will drive most programmers (including me) nuts.
Is it a correct assumptiont that if the grid control loses focus, the SelectedItem remains, but the CurrentItem is lost?
In MVVM pattern, I would like to know what the SelectedRow is - can I bind the SelectedItem to my MVVM? Do I have to subscribe to the SelectionChanged event in order to keept his syncronization?
I got into this whole mess because I'm trying to manage the creation of a Row using RadGridView AddingNewDataItem. I thought that when this event was thrown, the grid would create a new row, bind it to SelectedItem (which would then push it to my VM so that I can provide default values), and update my RowDetailsTemplate accordingly. Lots wrong here: 1) AddNewDataItem requires a NewObject, 2) the new Object does not become the SelectedItem ( or it may, but the binding does not used to update the VM), and 3) it looks like the RowsDetailsTemplate is ignored in the InsertRow?
1) When the user clicks on the add row, how to I inform the VM, and get a row into the NewObject event arg (still new to this pattern)
2) How do I control the NewRowTemplate (my job this morning, so I have not researched this yet)
Although I would like to see more help in the documentation, I am very apprecative of the support via this forum. Please let the powers at be know that it's the only reason why I'm using Telerik as a thrid party control - something that I have never done before when building client apps.