Announcement

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

    about ListGrid formula

    1.SmartGWT smartgwt-5.0p
    2.requiement:

    I need a formula fields in ListGrid, the formula is "FieldA+FieldB".
    There is no problem when this value of FieldA and FieldB is not null.
    But,if value of FieldA is null,I wish use 0 instead null, how should I do?


    3. my code:
    Code:
       UserFormula userFormula = new UserFormula();
       
       Map<String, String> map = new HashMap<String, String>();
       map.put("A", "FieldA");
       map.put("B", "FieldB");
    
       userFormula.setFormulaVars(map);
       //userFormula.setText("A+B");      //if use this statement, if value of FieldA is null, the result is null
       userFormula.setText("(A==null?0:A)+B");     //  no effect with  A==null condition
    
       
       ListGridField  formulaField = new ListGridField("sum", "sum");
       formulaField .setUserFormula(userFormula);
    4. How should I do? Thanks.
    Last edited by jackzk; 10 Jul 2015, 18:31.

    #2
    Hi jackzk,

    a workaround would be to use a customSelectExpression in your .ds.xml, e.g. customSelectExpression="NVL(myField, 0)".

    I don't know if the current behaviour you are seeing is on purpose, though.

    Best regards
    Blama

    Comment


      #3
      Originally posted by Blama View Post
      Hi jackzk,

      a workaround would be to use a customSelectExpression in your .ds.xml, e.g. customSelectExpression="NVL(myField, 0)".

      I don't know if the current behaviour you are seeing is on purpose, though.

      Best regards
      Blama

      Hi Blama,thanks for your help.
      my scenarios:
      I want compute summary of cost. Cost is consist of muti-item, but not all item will produce cost.
      For easy, I don't want to input 0 for these items.
      And for good-looking, I don't want set default value 0 for these items.
      Last edited by jackzk; 10 Jul 2015, 18:29.

      Comment

      Working...
      X