Announcement

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

    Dynamically filtering (using setOptionOperationId) CONCERN

    FF 5.0
    GWT 2.4
    SGWT Power 3.0p (From dev console ==> SmartClient Version: v8.2p_2012-06-30/PowerEdition Deployment (built 2012-06-30) )

    I have a use case where I need a SelectItem to display the list based on an option which user has selected. The list is rendered
    via the setPickListProperties and the underlying picklistProperty field allows for filtering.

    The problem : On selecting to filter by either rule, the list displays the expected rows. However if the search feature of the pickListProperty field
    is used, you are able to locate entries which aren't in the filtered list.

    Below is the code which I am using as a test (its almost as good as a stand alone test case).

    Code:
       public void onModuleLoad() {
    
        	
        	DynamicForm mainForm = getMainForm();
        	RootPanel.get().add(mainForm);
        }
        
        
        private DynamicForm getMainForm() {
        	final DynamicForm form = new DynamicForm();
        	
        	
            form.setHeight(105);
            form.setWidth100();
        	
    		final ListGrid pickListProperties = new ListGrid();
    		
    		pickListProperties.setShowFilterEditor(true);
    		pickListProperties.setFilterOnKeypress(true);
    		pickListProperties.setFetchOperation("dummytest3"); //Initialize here for initial restrictions
    
    		pickListProperties.filterByEditor();
    
            final SelectItem fsId = new SelectItem("FSID") ;
            ListGridField f1Field = new ListGridField("F1ID");
            ListGridField f2Field = new ListGridField("F2ID");
            ListGridField f3Field = new ListGridField("F3ID");
            ListGridField f4Field = new ListGridField("F4ID");
            f3Field.setWidth(100);
            
            
            fsId.setOptionDataSource(DataSource.get("TABLENAME"));
    
            fsId.setValueField("F1ID");
            fsId.setDisplayField("F2ID");	                
            fsId.setOptionOperationId("dummytest3");
            fsId.setPickListWidth(420);
            
            fsId.setPickListFields( f1Field, f2Field,f3Field,f4Field);
            fsId.setPickListProperties(pickListProperties);
            
            fsId.setEndRow(true);
            
            
            ButtonItem b1 = new ButtonItem();
            b1.setTitle("FS - D1");
            
    		//Simulate the user selection of filter rule 1
            b1.addClickHandler((new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    					SC.say("b1 pressed - DUMMYTEST1");
    
    					//Set both filter operations ,ie on the SelectItem and ListGrid
    					
    	                fsId.setOptionOperationId("dummytest1");					
    					pickListProperties.setFetchOperation("dummytest1");
    			}
    			}));        
               
    
            ButtonItem b2 = new ButtonItem();
            b2.setTitle("FS - D3");
    
    		//Simulate the user selection of filter rule 2
            
            b2.addClickHandler((new ClickHandler() {
    
    			@Override
    			public void onClick(ClickEvent event) {
    					SC.say("B2 pressed - DUMMYTEST3");
    					
    					//Set both filter operations ,ie on the SelectItem and ListGrid
    					
    	                fsId.setOptionOperationId("dummytest3");					
    					pickListProperties.setFetchOperation("dummytest3"); 
    			}
    			}));        
            
            
            
            b1.setEndRow(false);
            b2.setStartRow(false);
            
            form.setNumCols(4);
    
            //Setup the FORM fields
            form.setFields(fsId,b1,b2);
            return form;
            
        }
    The *.ds.xml entries are straight forward queries and as mentioned returns the expected rows.


    Let me know what I am missing as I suspect I have overlooked something.

    #2
    To further clarify the failure. In the example shown in previous post, we have two operationIds on the data source , dummytest1 and dummytest3 , where dummytest3 is the default operationId. If we click the button which forces the filter using operationId dummytest1 then we can via the filter editor search for items which aren't returned in the resultset of dummytest1. If we clear the search editor of the picklist, the listgrid returns the resultset of dummytest3 (not dummytest1 as was filtered).
    If however we select filtering by dummytest3 , we are restricted to filtering in that resultset. It seems the default filtering on the listgrid is taking precedence once you start entering data in the filter editor fields.
    Is there something I'm missing ? Is what I'm attempting allowed, ie to dynamically update the setFetchOperation of a ListGrid.

    Another question, why do I have to set the setFetchOperation of the listGrid if I set the filtering rules of the driving SelectItem via setOptionOperationId.
    It seems to me that one of the calls is redundant (in particular the ListGrid.setFetchOperation) as
    a. we already have the SelectItem obeying the filtering rules (via setOptionOperation)
    b. the SelectItem's pickListProperties referring to the ListGrid
    c. the only reason for introducing the ListGrid (and configuring the properties) is solely for the filter editor capabilities

    Please let me know if this is the expected behaviour of the Framework. I think there are some issues here. If not, let me know suggested approach to have the searches honour the rules of the last SelectItem.setOptionOperation (and/or ListGrid.setFetchOperation)

    Comment


      #3
      Setting the optionOperationId on the fly isn't currently supported. If you think about how complicated it is to capture the general case (what happens if it's changed when results are partially loaded and a request is outstanding, for instance), you'll see why.

      Instead, rearrange your code so that the information the DataSources needs to return correct results is expressed as part of the normal criteria.

      Comment


        #4
        Thanks for the response. Setting the optionOperationId on the fly seems to work fine, its the ListGrid where I see the problem. When we start associating the SelectItem's pickListProperties of the ListGrid and try to make use of the ListGrid's filtering options , this is where the two components seem not to be talking to each other. In other words, if I took out the filtering feature for the ListGrid everything works fine, but the users want to search for items in the SelectItem and the ability to choose the column on which to search ... a feature which is exposed to them on other less challenging screens ... . If any further considerations on how to proceed, it would be appreciated as I feel stomped.

        Comment


          #5
          In addition to not changing the optionOperationId on the fly, you also can't change the pickListProperties object on the fly after the SelectItem has been created. It's a one-time initialization, not a live connection.

          Comment


            #6
            Thanks again. I will revisit the approach as you initially suggested.

            Comment

            Working...
            X