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
70
XamdataGrid SelectedItem setter called with wrong value
posted

  • 28950
    Verified Answer
    Offline posted

    Hello Harry,

    Thank you for your post.

    I'd like to preface the following by saying that the behavior you are seeing is actually expected. This is due to a couple of reasons – the main one being that there are actually two “selection” states that a record or cell can actually be in, selected and active. In the case of your click on the “Child A1” checkbox, the record is active, but not selected.

    “Active” is synonymous with “focused” in this case, and it is currently impossible in the XamDataGrid to have a selected record while any cell or record is in “edit mode.” The CellClickAction defaults to “EnterEditModeIfAllowed” and so when you click on the checkbox in this case, the record actually is going into edit mode in that the embedded XamCheckEditor to your CheckBoxField is being focused. If the cell that is clicked on with CellClickAction set to “EnterEditModeIfAllowed” is not editable, the record will then be selected.

    When you set the CellClickAction to “SelectRecord” the selection takes precedent, which is why you need to click multiple times to get the checkbox value to change. In order to place a cell into edit mode with CellClickAction set to “SelectRecord,” you need to double-click the cell. I would also expect that you would see the SelectedItem setter in the case of your sample code be hit with a null value when this happens because again, records are not selectable when they are in edit mode.

    The best recommendation that I can make in this case is that you continue with CellClickAction.EnterEditModeIfAllowed, but check the ActiveCell.IsInEditMode property of your XamDataGrid. If this returns true, assuming ActiveCell is not null, you can make the assumption that there will be nothing selected in the XamDataGrid owning that cell. You may also be able to make use of the ActiveDataItem and ActiveRecord properties of the grid as well.

    Please let me know if you have any other questions or concerns on this matter.