Announcement

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

    Can't dynamically update valueMap for Filter options in ListGrid.

    We're using SmartGWTPro 4.1.

    We have a ListGrid with filtering enabled:
    issueListGrid.setShowFilterEditor(true);

    For every new load of data we wan't to update the filter option valueMaps - but the values entered the first time around are persistent and NEVER updated.

    Here's the core of the update function following each load (trivial stuff not included):

    Code:
    void updateGrid(List<T> listOfIssues) {
    dataSource = new DataSource();
    dataSource.setClientOnly(true);
    faultMap.clear();
    
    IssueListRecord[] issues = new IssueListRecord[listOfIssues.size()];
    for (Issue issue : listOfIssues) {
        //faultMap & issues are populated here
    }
    
    DataSourceTextField dsFaultField = new DataSourceTextField("fault","Fault");
    dsFaultField.setCanEdit(false);
    dsFaultField.setCanFilter(true);
    dsFaultField.setValueMap(faultMap); //should update filter options for this field
    ...other fields
    
    dataSource.setFields(..., dsFaultField ,...);
    for (IssueListRecord issueListRecord : issues) {
    	dataSource.addData(issueListRecord);
    }
    
    issueListGrid.setDataSource(dataSource, issueListGrid.getAllFields());
    
    ...updating currentCriteria according too prior selections
    issueListGrid.fetchData(currentCriteria);
    }
    We've tried different versions of putting in
    Code:
    issueListGrid.setShowFilterEditor(false);
    issueListGrid.setShowFilterEditor(true);
    which was mentioned in another post as re-initializing the filterEditor, but to no awail.

    #2
    If you tried to execute this code after you've already created a ListGrid bound to your DataSource:

    Code:
    dsFaultField.setValueMap(faultMap);
    .. it would actually just throw an exception (since you can't modify dataSourceField.valueMap on the fly). So your code that attempts to update the valueMap probably isn't running at all.

    As far as the right way to update just the valueMap used by the filterEditor, you would modify listGridField.filterEditorValueMap via listGrid.setFieldProperties().

    This code is also wrong:

    Code:
    dataSource.setFields(..., dsFaultField ,...);
    for (IssueListRecord issueListRecord : issues) {
    	dataSource.addData(issueListRecord);
    }
    See DataSource.setCacheData() for the correct way of populating a clientOnly DataSource.

    Comment


      #3
      Thanks for the quick reply and great pointers.

      I'm just the repair guy on this problem and I usually use DataSource.setCacheData(), so that was quickly back to normal.

      It seems ListGrid.setFieldProperties() is no longer in the API, but I solved the issue by looking closer at ListGridField and finding setFilterEditorValueMap ;)

      Comment

      Working...
      X