Announcement

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

    Autofilter for cell formatted field

    SmartClient Version: v11.0p_2017-02-11/PowerEdition Deployment (built 2017-02-11)

    I am using ds files.
    I have a field defined as : <field name="listPrice" type="float" title="List Price" width="70" format="$#,##0.00"/>

    On client side, i have set the formatter as :
    ListGridField listPriceField = new ListGridField("listPrice", "List Price");
    listPriceField.setCellFormatter(new CellFormatter() {

    @Override
    public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    if (value == null)
    return null;
    NumberFormat nf = NumberFormat.getFormat("#,##0.00");
    try {
    return "$" + nf.format(((Number) value).floatValue());
    } catch (Exception e) {
    return value.toString();
    }
    }
    });

    I have set autofilter to true. But i am not able to enter any number. I need to enter $ before entering a number.
    However,, when i enter $ followed by number, i do not get any result. Where am i going wrong.

    #2
    Filtering is based on the underlying numeric value, not the formatted value. This is the only possible way things could work, since the values in the database do not have the formatting.

    If you want to allow end users to type in the "$" or other parts of the formatting and have those ignored, you could add a FilterEditorSubmitHandler and modify the criteria to strip out format characters entered by the user.

    Comment

    Working...
    X