Announcement

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

    Using FilterBuilder to specify specific detail fields

    Hi,

    Using the FilterBuilder, is there a way to search for Master Fields by specifying specific detail fields?
    I.e. given the following DSs
    Code:
       	 setID(id);
            setRecordXPath("/List/d");
            DataSourceIntegerField pkField = new DataSourceIntegerField("id");
            pkField.setHidden(true);
            pkField.setPrimaryKey(true);
            addField(pkField);
    
            DataSourceTextField countryCodeField = new DataSourceTextField("n", "Master");
            countryCodeField.setRequired(true);
            addField(countryCodeField);
    
            DataSourceTextField traits = new DataSourceTextField("e", "Detail");
            traits.setChildrenProperty(true);
            traits.setMultiple(true);
            traits.setForeignKey("DetailDS.id");
            traits.setDisplayField("n");
            addField(traits);
    
            setDataURL("Master.data.xml");
            setClientOnly(true);
    and
    Code:
      setID(id);
            setRecordXPath("/List/t");
            DataSourceIntegerField pkField = new DataSourceIntegerField("id");
            pkField.setHidden(true);
            pkField.setPrimaryKey(true);
            addField(pkField);
    
            DataSourceTextField nameField = new DataSourceTextField("n", "Name");
            nameField.setRequired(true);
            addField(nameField);
    
            setDataURL("Detail.data.xml");
            setClientOnly(true);
    and Code
    Code:
    @Override  
        public void onModuleLoad() {
            
            final ListGrid listGrid = new ListGrid();
            listGrid.setDataSource(MasterDS.getInstance());  
            listGrid.setWidth(1200); 
            listGrid.setHeight(600);;  
            listGrid.setShowFilterEditor(true);
            listGrid.setUseAdvancedFieldPicker(true);
            listGrid.setAlternateRecordStyles(true);  
            listGrid.setAutoFetchData(true);  
            listGrid.setCanEdit(false);  
            listGrid.setCanRemoveRecords(false);
            listGrid.setCanMultiSort(true);
            listGrid.setShowFilterEditor(true);
             
            
            ListGridField detailField = new ListGridField("e", "Detail");
            detailField.setOptionDataSource(DetailDS.getInstance());
            detailField.setMultiple(true);
            detailField.setDisplayField("n");
            detailField.setValueField("id");
            detailField.setAutoFetchDisplayMap(true);
            detailField.setSortByDisplayField(true);
            
        	final FilterBuilder filterBuilder = new FilterBuilder();  
            filterBuilder.setDataSource(MasterDS.getInstance());
     
            ListGridField nameField = new ListGridField("n", "Master");
            nameField.setWidth(200);
            listGrid.setFields(nameField, detailField);  
    
            VLayout layout = new VLayout(15);
            IButton filterButton = new IButton("Filter");  
            filterButton.addClickHandler(new ClickHandler() {  
                public void onClick(ClickEvent event) {  
                    listGrid.filterData(filterBuilder.getCriteria());  
                }  
            });  
      
            layout.addMember(filterBuilder);  
            layout.addMember(filterButton);  
            layout.addMember(listGrid);  
            
            layout.draw();  
        }
    is it possible to formulate a query like “Detail field contains detail1 and detail2 and not detail3” to return corresponding Master fields?
    Using the standard filter Editor (above the grid), it is possible to formulate “or” queries like “Detail field contains detail1 or detail2 or detail3” which work without problems. Since I need more complex queries, I tried the FilterBuilder but it did not generate proper Critieria even when simulating the filter Editor.

    I.e. When selecting some values in its SelectItem, the filter Editor generates

    Code:
      criteria:[
                {
                    fieldName:"e", 
                    operator:"inSet", 
                    value:[
                        3, 
                        2
                    ]
                }
            ]
    whereas the FilterBuilder (using “is one of”) generates criterias like
    Code:
      criteria:[
                {
                    operator:"inSet", 
                    fieldName:"e", 
                    value:[
                        null, 
                        null
                    ]
                }
            ]
    In addition, I cannot properly set the detail fields in the FilterBuilder (i.e. values are forgotten and in the field it just shows detail7, detail7 when in fact detail6, detail5 was selected; see screeshot). This all looks like a bug to me. An Eclipse project showing the issue is here (https://dl.dropboxusercontent.com/u/...tailFilter.zip) for reference (LGPL libs need to be put in libs and the project needs to be compiled).

    Thanks & cheers,
    fatzopilot

    SGWT: SmartClient Version: v9.1d_2014-02-26/LGPL Development Only (built 2014-02-26)
    GWT: 2.6.0
    Browser: FF 26.0 (dev mode), Chrome 33.0.1750.154 m (prod mode)
    Attached Files
    Last edited by fatzopilot; 2 Apr 2014, 00:46.

    #2
    Hi,

    attached code for showcase integration demonstrates the same issue.

    Regards,
    fatzopilot

    SmartClient Version: SNAPSHOT_v10.0d_2014-04-12/LGPL Development Only (built 2014-04-12)
    Attached Files

    Comment


      #3
      Its looks like you just needed to setValueField() on your "multi" field that has the optionDataSource

      Comment


        #4
        Actually, you were right - there was a bug here which has now been addressed - please retest with a build of 9.1 or 10.0 dated May 4 or later.

        Comment


          #5
          Yepp, that did it, thank you for the fix!

          Comment

          Working...
          X