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
280
EmbeddableEditor display value caching
posted

I am using an IEditorDataFilter to control how my data is displayed. The display of the data changes depending on whether the cell is active (i.e. in edit mode). This causes issues with the default behavior of UltraGrids sharing editors with other columns of the same style/among cells in the same column, as when the editor is in edit mode, it uses a cached result instead of getting the value from the IEditorDataFilter, even though the cached value is for a different cell.

For example, suppose I want the decimal 0 to be displayed as "0" when not in edit mode and as "0.0" when in edit mode, and both cell a and cell b have a value of 0. If cell a is in edit mode and I mouseover to cell b, then cell b will also display as "0.0" even though it is not in edit mode.

Currently, the only way to avoid this seems to be to set the editor of each cell to a separate object, which seems like a waste of memory. Is there a better way of accomplishing what I am trying to do?

Parents
  • 469350
    Offline posted

    Hi,

    I think the problem must be in the way in which you are checking for Edit mode. The editor serves the entire column, so if you are simply checking conversionArgs.Editor.IsInEditMode then that will only tell if is a cell is in edit mode somewhere, not necessarily the cell the cell for which the DataFilter is currently firing.

    I think what you need to do is cast conversionArgs.Context into an UltraGridCell and then check the cell's IsInEditMode property.

    UltraGridCell cell = conversionArgs.Context as UltraGridCell;            
    bool isInEditMode = cell.IsInEditMode;

    I'm not entirely sure that the Context will always return a cell, though, so you should probably check for null and put in an assert to detect if it ever gets in there with some other object.

Reply Children