Announcement

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

    Locales and filter expressions

    Hi,

    I use locales in order to display number values in specific formats. It works fine except when setting filter expression.
    The decimal separator for a given local is comma. If I enter that as an input, it works but got translated as dot (as depicted).

    I tried to customise that via custom formatters and filtereditorproperties as shown but the particular column seems to be ignored.

    Any clue would be appreciated.

    Many thanks
    Petr

    Code:
    ListGridField lgf = new ListGridField(dsField.getName());
    FormItem editor = new FormItem();
    editor.setEditorValueFormatter(new FormItemValueFormatter() {
        @Override
        public String formatValue(Object value, Record record, DynamicForm form,
                                  FormItem item) {
          /// does not get here
        }
    });
    editor.setValueFormatter(new FormItemValueFormatter() {
        @Override
        public String formatValue(Object o, Record record, DynamicForm dynamicForm, FormItem formItem) {
           /// does not get here
            return null;
        }
    });
    lgf.setFilterEditorProperties(editor);


    #2
    We tried your approach and it worked as expected. However, note the simpler way to do this is to set your locale properly and then use the localeInt/localeFloat types, which provide automatic locale-specific formatting. Even if you wanted custom formatting, the better way to do it is to define a SimpleType so that you reuse formatting rules across all component types.

    Tested code
    Code:
        ListGrid listGrid = new ListGrid();
        listGrid.setWidth(400);
        listGrid.setHeight(200);
        listGrid.setDataSource(DataSource.get("supplyItem"));
        listGrid.setAutoFetchData(true);
        listGrid.setShowFilterEditor(true);
        ListGridField lgf = new ListGridField("unitCost");
        FormItem editor = new FormItem();
        editor.setEditorValueFormatter(new com.smartgwt.client.widgets.form.FormItemValueFormatter() {
           public String formatValue(Object value, Record record, DynamicForm form,
                                     FormItem item) {
            if (value == null) return null;
            return value.toString();
           }
        });
        editor.setValueFormatter(new com.smartgwt.client.widgets.form.FormItemValueFormatter() {
           @Override
           public String formatValue(Object o, Record record, DynamicForm dynamicForm, FormItem formItem) {
               /// does not get here
               return null;
           }
        });
        lgf.setFilterEditorProperties(editor);
        listGrid.setFields(lgf);
        listGrid.draw();
    Regards
    Isomorphic Software

    Comment

    Working...
    X