Hello,
I have a xamGrid with a dynamic columns. In my Xaml i don't know what column i will have in my ItemsSource. It might contain ComboBox column and DateTime column (with DatePicker).
I want the functionality that only on Enter click the new row will be added or Edit finished. And on escape - adding/editing will be cancelled. Clicking outside the XamGrid Won't do nothing.
How can i do it?
I search in your forums- i found something similar- but there the XamGrid columns are not dynamic as in my case.
Thank you for your post. I have been looking into the functionality that you wish to implement and I have modify the sample application from the following post: http://es.infragistics.com/community/forums/p/71150/360473.aspx#360473 in order to achieve you goal. To do that I have set the AutoGenerateColumns property to true and handled the PreviewKeyDown event of the e.Cell.Control in the CellControlAttached event and if the enter key is pressed, I am calling the ExitEditMode method of the XamGrd. I am using the preview event, since the KeyDown event is internally handled for the ComboBox and the DatePicker, which prevents the bubbling of the event to the CellControl.
If you need any further assistance please do not hesitate to ask.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Thanks.
one of my columns can be Date with DatePicker.
two things:
1. DatePicker is not opened on edit row (it is opened on AddNewRow)
2. I need same functionally (enter for adding/edit row, escape for cancel add/edit).
Also i want a functionality- when XamGrid loses focus (user clicked on another control), than editing/adding will be cancelled as well. How can i do it? I tried with XamGrid lost focus event, but it is being fired also when clicking in a cell in the XamGrid, and than add/editing is cancelled as well.
Thank you for your reply. I have been looking into it and in order to have the same functionality as when the escape key is pressed, when you change the focus to different element of the XamGrid, I can suggest adding the following code in the LsotFocus event of the XamGrid:
private void xamGrid1_LostFocus(object sender, RoutedEventArgs e) { var focused = FocusManager.GetFocusedElement(this); if (focused == null) return; XamGrid grid = Utilities.GetAncestorFromType(focused as DependencyObject, typeof(XamGrid), false) as XamGrid; if (!focused.Equals(sender) && grid != sender) { escape = true; (sender as XamGrid).ExitEditMode(true); } }
By doing so, you be able to determine whether element that is currently focused is the XamGid of some of its child elements and if not you can exit edit mode using the ExitEditMode method of the XamGrid and by setting the escape flag to true.
Regarding your other questions, I am not completely sure what is the exact functionality that you are trying to achieve. Would you please provide me with more detailed description of your goal, in order to be able to assist you more accurately?
Looking forward to hearing from you.
I am just checking if you require any further assistance on the matter.
There is a bug in XamGrid.
When a cell has validation error, and without exiting adding/editing row, i change the dataContext and ItemsSource of the XamGrid. Than internal exception from XamGrid code is thrown- invocation target exception
Thank you for your reply. I have been looking into your question and it seems to be the same as the one that you are having at the following forum thread, to which Petar has already replied: http://es.infragistics.com/community/forums/p/71862/363930.aspx#363930
If you need any further assistance on the matter, please do not hesitate to ask.