1. #1
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    128
    Vote Rating
    0
    vkeswani is on a distinguished road

      0  

    Default Unanswered: Gird filtering issue on BigDecimal Column values

    Unanswered: Gird filtering issue on BigDecimal Column values


    I have implemented grid filtering using simple example as shown in gxt explorer FilterGrid.
    I have applied NumericFilter on a value returning an amount value which is BigDecimal.
    Everything works as expected - the filter shows up on the column header with >,< and = , however while > and < work as expected the "=" operator doesn't work and returns no values.

    Please suggest.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Posts
    1,926
    Vote Rating
    55
    Answers
    73
    Colin Alworth is a jewel in the rough Colin Alworth is a jewel in the rough Colin Alworth is a jewel in the rough

      0  

    Default


    As each numeric type has different ways of checking, and as developers haven't been thrilled with the prospect of a dozen different filter objects for each possible comparable type, we have a default implementation to compare them. It turns out that java.lang.Number doesn't implement java.lang.Comparable, and the >, <, >=, <= operators don't work on BigDecimal or some other non-primitive Number classes.

    We could add a compare method into the NumberPropertyEditor and subclasses, but that would come at the cost of causing changes in other projects. Instead, NumericField has two methods designed to be overriden in cases such as yours - greaterThan(V,V), and equals(V,V). In both cases, V is the numeric type you are working with.

    We're open to thoughts and suggestions on how this api can be improved to be as flexible as possible, but try starting with these and seeing where you can get.

  3. #3
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    128
    Vote Rating
    0
    vkeswani is on a distinguished road

      0  

    Default


    Thanks Colin.

    Yes I did a small test with compareto instead of "equals" and that works well with BigDecimal. Overriding could be the workaround.