Announcement

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

    Possible bug (got warning) in ListGrid Filter w/ optionDataSource + setSortField

    Hi Isomorphic,

    I have a list grid with an foreign key column displaying its father's data. This works fine. I set the ListGrid to setShowFilterEditor(true).
    In order to see all the possibilities to filter for, I create a new SelectItem to use as FilterEditor with
    Code:
    	SelectItem anredeIdSI = new SelectItem("ANREDE_ID") {
    		{
    			setValueField("ID");
    			setDisplayField("NAME");
    			setOptionDataSource(anredeDS);
    			//setSortField("NAME");
    		}
    	};
    	anredeIdLGF.setFilterEditorType(anredeIdSI);
    This works as expected as well, but the data in the filter is not sorted. If I now remove the comment in above code, the list gets sorted as expected, but I also get one single warning when showing the widget. I can use the widget as expected then.

    The warning is
    "13:37:52.317:MUP7[E]:WARN:PickListMenu:isc_PickListMenu_4:fields and completeFields are null and there is no DataSource"

    Code:
    13:37:52.289 [ERROR] [myproj] 13:37:52.317:MUP7[E]:WARN:PickListMenu:isc_PickListMenu_4:fields and completeFields are null and there is no DataSource
    com.smartgwt.client.core.JsObject$SGWT_WARN: 13:37:52.317:MUP7[E]:WARN:PickListMenu:isc_PickListMenu_4:fields and completeFields are null and there is no DataSource
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:105)
        at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
        at com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172)
        at com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServer.java:292)
        at com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelServer.java:546)
        at com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
        at java.lang.Thread.run(Unknown Source)
    From my forum reading this *might* be connected to http://forums.smartclient.com/showthread.php?t=12913 (same warning, widget working as expected).

    As I think it is somehow connected to the setSortField("NAME"), it might be easiest for you to reproduce in showcase http://www.smartclient.com/smartgwte...e_valuemap_sql which already uses setFilterEditorType() with an (unsorted) ComboBoxItem.

    Best regards,
    Blama

    PS: Tested with current 3.0 eval, FF9.0.1 in GWT development mode.

    #2
    Are you saying it *can* be reproduced in the Showcase? If so, just show exact changes needed to repro the problem, other details are not needed.

    Comment


      #3
      Hi,

      just imported the showcase. I can reproduce it (full replace of LargeValueMapSQLSample):
      Code:
      package com.smartgwt.sample.showcase.client.dataintegration.java.sql;
      
      import com.smartgwt.client.data.DataSource;
      import com.smartgwt.client.widgets.Canvas;
      import com.smartgwt.client.widgets.form.fields.SelectItem;
      import com.smartgwt.client.widgets.form.fields.ComboBoxItem;
      import com.smartgwt.client.widgets.form.fields.FormItem;
      import com.smartgwt.client.widgets.grid.ListGrid;
      import com.smartgwt.client.widgets.grid.ListGridField;
      import com.smartgwt.sample.showcase.client.PanelFactory;
      import com.smartgwt.sample.showcase.client.ShowcasePanel;
      
      public class LargeValueMapSQLSample extends ShowcasePanel {
      
      	private static final String DESCRIPTION = "<p>This example shows the simple use of custom SQL clauses to provide a DataSource that joins multiple tables while retaining SmartGWT's "
      			+ "automatic paging and filtering behavior. When trying this example, remember that this is <b>automatic</b> dataset-handling behavior that "
      			+ "works without any coding, even though the data is being provided by a custom SQL query.</p>"
      			+ "<p>The list contains order items; each order item holds an itemID, which is being used to join to the supplyItem table and obtain the "
      			+ "itemName. Note that you can filter on the itemName - either select a full item name or just enter a partial value in the combo box. "
      			+ "Pagination is also active - try quickly dragging the scrollbar down, and you'll see SmartGWT contacting the server for more records.</p>"
      			+ "<p>Editing is also enabled in this example. Try filtering to a small sample of items, then edit one of them by double-clicking it and choose "
      			+ "a different item. Note how that order item is immediately filtered out of the list: SmartGWT's intelligent cache sync also automatically "
      			+ "handles custom SQL statements.</p>";
      
      	public static class Factory implements PanelFactory {
      		private String id;
      
      		public Canvas create() {
      			LargeValueMapSQLSample panel = new LargeValueMapSQLSample();
      			id = panel.getID();
      			return panel;
      		}
      
      		public String getID() {
      			return id;
      		}
      
      		public String getDescription() {
      			return DESCRIPTION;
      		}
      	}
      
      	protected boolean isTopIntro() {
      		return true;
      	}
      
      	public Canvas getViewPanel() {
      		DataSource dataSource = DataSource.get("largeValueMap_orderItem");
      		final DataSource feds = DataSource.get("supplyItem");
      
      		final ListGrid orderListGrid = new ListGrid();
      		orderListGrid.setWidth(550);
      		orderListGrid.setHeight(224);
      		orderListGrid.setDataSource(dataSource);
      		orderListGrid.setAutoFetchData(true);
      		orderListGrid.setShowFilterEditor(true);
      		orderListGrid.setCanEdit(true);
      
      		ListGridField orderIdField = new ListGridField("orderID");
      		ListGridField itemIdField = new ListGridField("itemID", "Item Name");
      		itemIdField.setWidth("50%");
      		itemIdField.setEditorType(new SelectItem());
      
      		//This causes a warning 
      		ComboBoxItem cbi = new ComboBoxItem() {
      			{
      				setOptionDataSource(feds);
      				setValueField("itemID"); //not needed? (because this field is PK?)
      				setDisplayField("itemName"); //not needed? (because this field is title-field of DS?)
      				setSortField("itemName");
      			}
      		};
      
      		itemIdField.setFilterEditorType(cbi);
      		itemIdField.setDisplayField("itemName");
      
      		//This doesn't cause a warning 
      //		FormItem feProps = new FormItem() {
      //			{
      //				setOptionDataSource(feds);
      //				setValueField("itemID"); //not needed? (because this field is PK?)
      //				setDisplayField("itemName"); //not needed? (because this field is title-field of DS?)
      //			}
      //		};
      //		itemIdField.setFilterEditorProperties(feProps);
      
      		ListGridField quantityField = new ListGridField("quantity");
      		ListGridField unitPriceField = new ListGridField("unitPrice");
      
      		orderListGrid.setFields(orderIdField, itemIdField, quantityField, unitPriceField);
      
      		return orderListGrid;
      	}
      
      	public String getIntro() {
      		return DESCRIPTION;
      	}
      
      }
      While trying I noticed that it might not be the correct way to pass a fully configured object to itemIdField.setFilterEditorType(). I should use itemIdField.setFilterEditorProperties() instead. Is that true?

      If so, I can get my sorting by making feProps ComboBoxItem instead of FormItem and adding sort via setSortField() to it.
      So most likely it is no error, but API-misuse on my behalf. Is there any way I can tell I'm using the API in the wrong way? Could you add a warning to setFilterEditorType()-javadoc telling the user just to insert plain objects there via "setFilterEditorType(new ComboBoxItem())"?

      My learning from this is: Always do a file level search for API name in the showcase when using a new API.

      Best regards,
      Blama

      Comment


        #4
        Hi Isomorphic,

        tried a little bit more. Now I'm sure it is a bug or at least not related to me misusing the API. Start with fresh LargeValueMapSQLSample.

        Change the following:

        Original:
        Code:
        FormItem feProps = new FormItem() {
        	{
        		setOptionDataSource(feds);
        	}
        };
        New:
        Code:
        ComboBoxItem feProps = new ComboBoxItem() {
        	{
        		setOptionDataSource(feds);
        		setSortField("itemName");
        	}
        };
        Changed from FormItem to ComboBoxItem as FormItem does not have the setSortField method.

        Result is the mentioned warning.

        Best regards,
        Blama

        Comment

        Working...
        X