Announcement

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

    ListGrid Filter Handling of Number Values vs Format

    I have a ListGrid with a Filter row:
    Code:
    ...
    listGrid.setShowFilterEditor(true);
    listGrid.setFilterOnKeypress(true);
    listGrid.setDataSource(ds_Employee);
    listGrid.setAutoFetchData(true);
    ...
    The ListGrid has a column:
    Code:
    ListGridField lgf_EmployeeId = new ListGridField("EMPLOYEE_ID", "Employee ID", 80);
    lgf_EmployeeId.setType(ListGridFieldType.INTEGER);
    
    lgf_EmployeeId.setCellFormatter(new CellFormatter() {
    
    	@Override
    	public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
    
    		// If there's no value to format, exit.
    		if (value == null) {
    
    			return null;
    
    		}
    
    		// Feed the value into the formatter & return it
    		try {
    
    			NumberFormat nf = NumberFormat.getFormat("000000");
    
    			return nf.format(((Number) value).doubleValue());
    
    		} catch (Exception e) { // If validation is correct, this should never happen.
    
    			return value.toString();
    
    		}
    
    	}
    
    });
    The Issue: The Filter header box search appears to act upon the underlying cell values, not the displayed format.

    Example: If the cells have the following values:
    10302
    3098

    The applied number format will display these values as
    010302
    003098

    However, a Filter search of "03" will return "010302" but not "003098" (because it's unformatted value is "3098" which does not contain "03").

    I'm guessing the issue would be addressed as described in the Javadoc for ListGrid.setShowFilterEditor? There is some sample code
    Code:
    var newCriteria = myListGrid.getFilterEditorCriteria();
        isc.addProperties(newCriteria, {
           field1:"new value1",
           field2:"new value2"
        });
        myListGrid.setCriteria(newCriteria);
    but I get lost at isc.AddProperties (that is not available in SGWT, is it?)

    Any guidance appreciated, thanks.


    SmartClient Version: v8.2p_2013-01-14/PowerEdition Deployment (built 2013-01-14)

    #2
    We don't filter using the formatted value because that value isn't available on the server.

    You seem to be looking to transform the criteria (perhaps by adding the prefix the formatter would add?) but that doesn't seem like it could work. However the addProperties() call is just the equivalent of calling Criteria.addCriteria() in SmartGWT.

    Probably the best approach here is to change the values at the earliest point possible, eg, with a SQL function, so that server filtering still works normally.

    Comment

    Working...
    X