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
3166
Understanding IEditorDataFilter Convert functionality
posted

I am not able to fully appreciate when IEditorDataFilter.Convert method gets called with different ConversionDirection.

Is there any document / article explaining this function ? And what is appropriate in various scenario.

For understanding, I prototyped one scenario where the column is bound to custom object. And I am implementing ConversionDirection.EditorToDisplay and ConversionDirection.EditorToOwner to get from and to the (custom object/grid). And its working for this scenario.

However I don't fully understand the function and its more of trial and error.

Parents
No Data
Reply
  • 469350
    Offline posted

    I don't think there's a whole lot of documentation on DataFilters.

    But here's a basic overview:

    There are 3 places that a value of a cell or an EditorControl are stored.

    • The Owner - The Owner is the back end value. In a grid cell, I think of the Owner value as the value that is stored in the grid's DataSource.
    • The Editor - The Editor is the object that handles the value in the cell. I think of this as the value in the cell. The Editor Value has to be of a type that the cell's editor can handle. So, for example, if you are using a DateTimeEditor in a cell, the editor can only handle DateTime values. The Owner value can be any type, but the Editor Value always has to be a DateTime.
    • The Display - This is what the user sees on the screen, so it's pretty much always a string. 

    The DataFilter will fire any time the grid or editor control needs to convert one type into another. For example, when the user types into a cell, they are essential altering the Display value. When they leave the cell, the display value has to be converted into an editor value so that the cell can store it. So the DataFilter fires with the EditorToDisplay conversion. Then the grid has to update it's DataSource, so it converts the Editor value into an Owner value, so the EditorToOwner conversion is called.

    When the grid is bound and creates the rows and cells for the first time, it has to do the reverse. It gets a value from the Owner and converts it to an EditorValue to be stored in the cell. So the OwnerToEditor conversion is called. Then when the cell is painted on the screen, it has to take the Editor value and display it, so it calls EditorToDisplay.

    There are some other special cases where these conversions may get called, but that's the basic overview.

Children
No Data