Announcement

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

    combobox inside listgrid after editing shows value not display

    I'm coming across a strange problem and I'm unsure if it's a bug, some failing of my own, or something that requires more cleverness to deal with. I'm trying to include a combobox inside of a listgrid, where the list grid starts empty and is added to by double clicking on the grid. This works fine except for when you're done editing the combobox and click enter, it shows the value instead of the display inside the list grid, though the combo box performs fine.

    What is going on with the listgrid showing the value instead of display for comboboxes? Here's some example code:
    Code:
    columns = new ListGrid(){{
    	setEditEvent(ListGridEditEvent.CLICK);
    	setListEndEditAction(RowEndEditAction.NEXT);
    	setCanEdit(true);									
    	setFields(new ListGridField("name", "Name"){{
    		setCanEdit(true);
    
    		setEditorType(new ComboBoxItem(){{
    			setTextMatchStyle(TextMatchStyle.SUBSTRING);
    			setAddUnknownValues(false);
    			setValueMap(new LinkedHashMap<String, String>(){{
    				put("valueThatShouldntBeSeen", "Should See Me");
    			}});
    		}});
    	}});
    	startEditingNew();
    }};

    #2
    You've given the valueMap to the ComboBoxItem, but not to the ListGrid - the ListGrid doesn't know about it.

    Assuming the real situation involves dynamic data and not just a static valueMap, see also listGridField.optionDataSource and dataSourceField.includeFrom.

    Comment


      #3
      We actually do use a static map, but one that is derived from a dynamic source. It looks like this:

      Code:
      final LinkedHashMap<String, String> attrMap = new LinkedHashMap<String, String>();
      for (Record attr : attrs){
      	final String name = attr.getAttribute("name");
      	String label = attr.getAttribute("label");
      	final String processedLabel = !StringUtil.isEmpty(label) ? label + " (" + name + ")" : name;
      	attrMap.put("attrs_" + name, processedLabel);
      }
      It would be optimal to plug the datasource directly in, but we need some processing. Given this, is it possible to get it to display right inside the list grid.

      Comment


        #4
        Certainly. As we just said, the grid needs the valueMap too (listGridField.valueMap).

        Comment

        Working...
        X