Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
AllowAddNew without allowing edit problems
posted

I have a XamDataGrid that I need the ability to add a new record but not edit existing records.

To get to where I am now, I have set the following:

grid.FieldLayoutSettings.AllowAddNew = true

for each column that the user can edit (some should not be editable):
     col.Settings.AllowEdit = true

in the OnEditModeStarting event, I check if the if e.Cell.Record.IsAddRecord is true.  If not, I cancel the event.

 

This works ok, but has the following effects that need to be rectified:

1. For columns that use a XamComboEditor or date editor as the editor, the down arrow icon shows up on mouse-over for every cell in the column, whereas I need it to show up only for the AddRecord.

2. For existing rows, I am capturing a doubleclick event to open a details screen.  I use the OnSelectedItemsChanged event to keep track of selected records.
When I double-click on a non-editable column, the event fires as expected.
When I doubleclick on an editable column,
   the OnSelectedItemsChanged event runs with no items selected,
   the OnDoubleClick event runs but nothing is selected at that point so event does not perform action
   the OnEditModeStarting event runs and is cancelled as expected
   the OnSelectedItemsChanged event runs with 1 Record selected.

If there is some way to turn off the ability to edit existing records, these side effects would not happen.  Is there any way to come to a solution on this?