Announcement

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

    ListGridField Picklist bugs

    I will write a test-case later today when I have a chance, but I have noticed two strange picklist bugs. My scenario is a picklist in a ListGridField, with mutliple=true and using an optionDataSource. I am using setPickListFilterCriteriaFunction to dynamically restrict the choices for a particular cell based on the row (and column - but these should be independent, however I noticed the ListGrid re-uses the picklist between columns, is there any way to make it not do that?).

    1) setPicklistProperties(ListGrid) - when I use this (which is great, because it allows me to make the customizations I want), I sometimes get an additional picklist checkbox appearing, and in subsequent clicks on the SelectItem I get more and mroe of these boxes. This only happens when I call setPicklistProperties.

    2) My picklist sometimes has boxes checked that are not actually the current selected values in the cell that is clicked. When I click on the cell a second time, the incorrect checks disappear. It is like the picklist has not been populated correctly.

    #2
    And this is with the current nightly, Eval EE

    Comment


      #3
      I still not have had a chance to write a test-case, but I wonder if anyone else has had this problem?

      The incorrectly ticked check-box is a bit of a show-stopper. Not being able to use setPicklistProperties is inconvenient.

      I'm considering making a custom cell editor as a workaround.

      Comment


        #4
        This bug, #2 in particular, is driving me nuts.

        I added a DataArrivedHandler to the SelectItem in question. I put a breakpoint in the DataArrivedHandler. When the bug happens (the incorrectly selected checkbox) the Picklist shows up before my breakpoint. When there is no bug, the Picklist shows up after.

        I'm really a bit at ends with this. Any suggestions for workarounds appreciated. For example, when I manually click on the picklist (to close and reopen it), the phantom check mark goes away. It's only the first time that it appears.

        It appears that it is definitely related to attaching a dynamic criteria that is dependent on the cell that is being edited. If I remove that there is no problem (but probably it's caching the data result, so maybe that is why).

        Any help greatly appreciated.

        The ugly workarounds I am considering are:
        * Write a custom picklist so I can control the contents
        * Change the datasource to return one shot of data (far from ideal)

        Comment


          #5
          Alternatively, if someone can show me some code that uses an optionDataSource for the pickList that has criteria that are dependent on the cell being edited, that would also be hugely helpful.

          Comment


            #6
            There are two Databound Dependent Selects in the Showcase, one for forms, one for grids.

            If you think there's a bug, we will need a test case - when there's just one person reporting a problem, prose descriptions just don't give us confidence we're going to find a bug if we look deeper.

            Comment


              #7
              I totally understand about the test case. I was skeptical that I could produce a standalone since my code is doing a server fetch for each cell's optionDataSource. But the following code shows the issue.

              The key characteristic that makes this bug appear is the use of dynamic criteria on the cell. See these tags in comments: CASE-1 and CASE-2. CASE-1 consistently reproduces the bug, but it's clearly not a normal use of criteria. CASE-2 intermittently has the the bug (and flickers a selected checkbox before redrawing).

              Code:
              		// the picklist datasource
              		DataSource optionDataSource = new DataSource();
              		{
              			DataSourceField keyField = new DataSourceField("key",
              					FieldType.SEQUENCE);
              			keyField.setPrimaryKey(true);
              			DataSourceField itemField = new DataSourceField("value",
              					FieldType.TEXT);
              			optionDataSource.setFields(keyField, itemField);
              			optionDataSource.setClientOnly(true);
              			optionDataSource.setAutoCacheAllData(true);
              			for (int i = 20; i < 30; i++) {
              				Record record = new ListGridRecord();
              				record.setAttribute("key", i);
              				record.setAttribute("value", i % 2 == 0 ? "OINK" : "MOO");
              				optionDataSource.addData(record);
              			}
              		}
              
              		// the grid datasource
              		DataSource dataSource = new DataSource();
              		{
              			DataSourceField key = new DataSourceField("key2",
              					FieldType.SEQUENCE);
              			key.setPrimaryKey(true);
              			DataSourceField value = new DataSourceField("value2",
              					FieldType.INTEGER);
              			value.setMultiple(true);
              			dataSource.setFields(key, value);
              			dataSource.setClientOnly(true);
              			for (int i = 0; i < 10; i++) {
              				Record record = new ListGridRecord();
              				record.setAttribute("key2", i);
              				dataSource.addData(record);
              			}
              		}
              
              		final ListGrid listGrid = new ListGrid();
              		listGrid.setEditOnFocus(true);
              		SelectItem selectItem = new SelectItem();
              		selectItem.setDefaultToFirstOption(false);
              		selectItem
              				.setPickListFilterCriteriaFunction(new FormItemCriteriaFunction() {
              					boolean flip = false;
              
              					@Override
              					public Criteria getCriteria(
              							FormItemFunctionContext itemContext) {
              						/*
              						 * a totally dynamic criteria consistently causes the
              						 * bug
              						 * 
              						 * CASE-1
              						 */
              						flip = !flip;
              
              						/*
              						 * if you do this, you can see it redraw (correctly)
              						 * over the first checkbox. i think the bug is that
              						 * sometimes this redraw does not happen - although it
              						 * begs the question, why does the first draw show the
              						 * checkbox? in this test case, it takes many clicks to
              						 * see the redraw not happen, but it did happen several
              						 * times to me with this exact code.
              						 * 
              						 * CASE-2
              						 */
              //						flip = listGrid.getEditRow() % 2 == 0;
              
              						// // waste some time
              						// for (int i = 0; i < Integer.MAX_VALUE/2; i++)
              						// if (i < 0)
              						// flip = !flip;
              
              						if (flip)
              							return new Criteria("value", "MOO");
              						else
              							return new Criteria("value", "OINK");
              					}
              				});
              
              		/*
              		 * try uncommenting these - i got this error:
              		 * 
              		 * [ERROR] [xxxx] 05:19:34.988:MUP6:WARN:Log:Call to Super for method:
              		 * $315 failed on: [PickListMenu ID:isc_PickListMenu_0]: couldn't find a
              		 * superclass implementation of : ScrollingMenu.$315
              		 */
              		// selectItem.setDisplayField("value");
              		// selectItem.setValueField("key");
              
              		listGrid.setCanEdit(true);
              		listGrid.setAutoFetchData(true);
              		listGrid.setDataSource(dataSource);
              		ListGridField listGridField = new ListGridField("value2");
              		listGridField.setEditorType(selectItem);
              		listGrid.setFields(listGridField);
              
              		addMember(listGrid);
              		addMember(new Label(
              				"Try using the picklist in this table.  Why is the first option already selected?"));

              Comment


                #8
                Can you try this against the latest nightly? There was a recent pick list-related regression and even more recent fix.

                Also, is the autoCacheAllData setting intended to be relevant to the test case? EditOnFocus?

                Finally, what's the expected and observed result - your original post talked about checkboxes but this test case doesn't have any.

                Comment


                  #9
                  I will download todays build to make sure. Yesterday (8pm PST) I downloaded the latest.

                  autoCacheAllData and editOnFocus don't seem to matter. The result seems to be the same.

                  The observed behavior is that an empty cell shows up with the first item selected in the picklist. The expected behavior is that an empty cell will show up with no items selected in the picklist (unless I specify defaultToFirst - which is not a case I am interested in).

                  Comment


                    #10
                    It appears the build I used is the latest (2011-04-19 Eval).

                    Comment


                      #11
                      any updates on this?

                      in the meantime, i've started working on my own picklist popup using the ideas in here http://www.smartclient.com/smartgwt/..._custom_picker

                      Comment


                        #12
                        Since you asked for last-call 2.5 bugs, this one still annoys me and I changed my code to not use a SelectItem. It seems like the bug could be some kind of race condition, but consistently reproduced if the criteria changes each time.

                        Comment

                        Working...
                        X