No announcement yet.
  • Filter
  • Time
Clear All
new posts

  • Custom Data Type in ListGrid vs. SortNormalizer


    I created a custom data type class (mySimpleMoney) which extends SimpleType. I've set the name property to 'myMoney' and the
    inheritsFrom property to 'float'.

    Whenever I embed a field with this type inside a listGrid, sorting doesn't work properly for that column (undefined fields don't get sorted). The
    only way I found to have this work was to define a sortNormalizer within my datasource, on every field occurrence for this custom data type. I
    believe this is somewhat cumbersome and error prone (not DRY at all).

    I noticed that the ISC framework will by default set field.type as the sortNormalizer when none is provided, but the problem I'm facing
    is that the underlying Array sorting method doesn't know about my custom data type.

    I'm trying to find a better approach to fixing this sorting issue with my custom data type, without the need to specify a sortNormalizer
    on each field instance, but rather inside the mySimpleMoney definition or override the Array _getNormalizerFromType() method. I'm
    looking for a do-once-and-forget solution so that my custom data type becomes a first class citizen and behaves properly in terms of sorting ...

    Any idea on where/how I could make this work in a more simple way?

    Once again, thanks for your help ...

  • #2
    We ultimately plan to expand the SimpleType system so that you can define custom methods for sort behavior, as well as filter, group, etc behaviors. In the meantime, the best practice is that whatever you store as your SimpleType value is an ordinary atomic type (String, Date, etc) that SC already understands how to sort, filter and group. You may *also* store a more expanded or convenient value in an additional fields.


    • #3
      Thanks for your reply,

      What we'll do for now is create a factory method that will attach a custom sortNormalizer to all
      mySimpleMoney fields created.

      Kind regards,