Go Back   SmartClient Forums > Technical Q&A
Wiki Register Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 13th Jul 2011, 03:55
yavery yavery is offline
Registered Developer
 
Join Date: Oct 2008
Posts: 408
Default Custom Data Type in ListGrid vs. SortNormalizer

Hi,

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 ...
Reply With Quote
  #2  
Old 13th Jul 2011, 09:30
Isomorphic Isomorphic is offline
Administrator
 
Join Date: May 2006
Posts: 38,393
Default

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.
Reply With Quote
  #3  
Old 13th Jul 2011, 13:08
yavery yavery is offline
Registered Developer
 
Join Date: Oct 2008
Posts: 408
Default

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,
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with contextMenu disappearing in 6/16 nightly senordhuff Technical Q&A 1 17th Jun 2011 15:04
alignment in prompt display senordhuff Technical Q&A 2 17th Jun 2011 10:09
Error message when using sample jsp file with 6/8 nightly senordhuff Technical Q&A 1 17th Jun 2011 08:20
Problems with customSQL query ttran Smart GWT Technical Q&A 16 17th Nov 2010 11:54
Slow script error occurring only when ListGrid columns are grouped senordhuff Technical Q&A 12 2nd Mar 2010 12:42

© 2010,2011 Isomorphic Software. All Rights Reserved