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
675
Cannot StartEditMode for activeCell?
posted

Hi, there

We are using Infragistics WPF4 version 10.3. And I'm running into this issue that I desparately need some help. Here's the requirement:

  1. I'm using XamDataGrid to present some data. AllowAddNew=true, UpdateMode="OnRecordChangeOrLostFocus"
  2. Only new record is editable. In another word, user can insert new record, but not edit existing record. They do have the option to delete a record through a delete image at the end of each row.
  3. We are using a customized editor for the first cell of our data, although I don't think this is the issue.
  4. We have a couple cells with AllowEdit set to false.
  5. When user tab through the fields, I want to skip the fields that are disabled (AllowEdit=false).
  6. The last field is also disabled, so when that field is skipped, I listen to the RecordUpdating event for error checking, and RecordUpdated event to save data. These all work fine.
  7. One more thing I need to do is that when the currentAddRecord is saved, I want to move the focus to the new currentAddRecord, and set the first cell into edit mode.
  8. What I did was to listen to ExecutedCommand for CellNextByTab command, if the current cell is disabled, execute another CellNextByTab to skip current cell.
  9. When I reach to the last cell of the row, I still need to skip (because last cell is disabled). The save is handled in RecordUpdated event. But the moving focus to new record part is handled in ExecutedCommand event. Here's my code:

this.gridWantListItems.ActiveRecord = gridWantListItems.RecordManager.CurrentAddRecord;

this.gridWantListItems.ActiveCell = gridWantListItems.RecordManager.CurrentAddRecord.Cells[0];

//CellValuePresenter cvp = CellValuePresenter.FromCell(gridWantListItems.ActiveCell);

//cvp.Editor.StartEditMode();

// enter edit mode

this.gridWantListItems.ExecuteCommand(DataPresenterCommands.StartEditMode);

The problem is that the cell does not go into edit mode. The same code executes in grid Loaded event, and the cell was put in edit mode. But here it does't. Notice the commented out line of CellValuePresenter code. If I uncomment that code, I can see cvp is null. Could this be the reason that StartEditMode does not put my cell into edit mode?

Any suggestion on how I can get the cell into edit mode?

Thanks.

Parents
No Data
Reply
  • 17559
    posted

    Hello rzhu,

     

    I was looking into you requirements and I can suggest you add the following code to the RecordUpdated event of the XamDataGrid:

            private void xdg_RecordUpdated(object sender, Infragistics.Windows.DataPresenter.Events.RecordUpdatedEventArgs e)

            {

     

                //// enter edit mode

                this.xdg.ActiveCell = (xdg.ActiveRecord as DataRecord).Cells[0];

                this.xdg.ExecuteCommand(DataPresenterCommands.StartEditMode);

     

            }

     

    This will force the first cell of the new added row automatically to get in edit mode right after the new row is being added. After this initial editing you can use the same event to restrict the cells to became read only, once this user navigates outside the row.

     

    If this doesn’t suit your scenario, could you please provide me with a small sample where the issue you are describing is reproducible, so I can continue investigating this.

Children