Announcement

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

    multi select keypress select

    I am seeing a weird behavior when I have a multi select and use the keyboard to select an item. If I use the mouse to select the items and get them as a string array, it seems to work. If I choose one item using the mouse, it also seems to work, and i get a String [] with one value in it. If I use the keyboard and select using the keyboard the value seems to be a String and if I try to get it as a String array, it gives me the name of the value parsed. below is sample code that illustrates the behavior.

    If I start editing new, select Manufacturing as the product, check with my mouse Design Development and Qa. Then i click my See dept value button and i see [Design ,Development ,QA ,] which is what i would expect
    If I change my dept selection to just design and then i click my See dept value button and i see [Design ,] which is also what i would expect
    If I clear all the values and the start typing a D in the field, to point where is goes through the D options and selects them, like a normal select item. i leave it on Development, click on see dept value and I get [D ,e ,v ,e ,l ,o ,p ,m ,e ,n ,t ,]

    Is there anyway to avoid this happening? Is there something I am missing that would easily correct this?

    Thank you.

    VLayout layout = new VLayout();
    final ListGrid grid = new ListGrid();

    Button button = new Button();
    button.setTitle("Start Editing new Row");
    button.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event)
    {
    grid.startEditingNew();
    }
    });
    layout.addMember(button);

    final Map<String, String[]> departments = new HashMap<String, String[]>();
    departments.put("Marketing", new String[]{"Advertising", "Community Relations"});
    departments.put("Sales", new String[]{"Channel Sales", "Direct Sales"});
    departments.put("Manufacturing", new String[]{"Design", "Development", "QA"});
    departments.put("Services", new String[]{"Support", "Consulting"});


    grid.setWidth100();
    grid.setHeight100();
    grid.setHeaderHeight(60);
    grid.setAlternateRecordStyles(true);
    grid.setShowSortNumerals(false);
    grid.setFilterOnKeypress(true);
    grid.setModalEditing(true);
    grid.setEditEvent(ListGridEditEvent.CLICK);
    grid.setAutoFetchData(true);
    grid.setEditByCell(true);
    grid.setValidateOnChange(false);
    grid.setCanReorderRecords(true);
    grid.setShowAllRecords(true);
    grid.setAutoSaveEdits(true);

    ListGridField product = new ListGridField("product", "Product");
    product.setType(ListGridFieldType.TEXT);
    product.setCanEdit(true);
    product.setValueMap("Marketing", "Sales", "Manufacturing", "Services");

    SelectItem deptSelect = new SelectItem();
    deptSelect.setAddUnknownValues(false);
    deptSelect.setMultipleAppearance(MultipleAppearance.PICKLIST);
    deptSelect.setMultiple(true);

    ListGridField dept = new ListGridField("dept", "Department");
    dept.setType(ListGridFieldType.TEXT);
    dept.setCanEdit(true);
    dept.setMultiple(true);
    dept.setEditorValueMapFunction(new EditorValueMapFunction()
    {
    public Map getEditorValueMap(Map values, ListGridField field, ListGrid grid)
    {
    Map<String, String> valueMap = new HashMap<String, String>();
    if (null != values.get("product"))
    {
    String product = values.get("product").toString();
    String [] depts = departments.get(product);

    for (int i = 0; i < depts.length; i++)
    {
    valueMap.put(depts[i], depts[i]);
    }
    }
    return valueMap;
    }
    });
    dept.setEditorProperties(deptSelect);

    grid.setFields(product, dept);
    layout.addMember(grid);

    Button valueB = new Button();
    valueB.setTitle("See dept value");
    valueB.addClickHandler(new ClickHandler() {

    @Override
    public void onClick(ClickEvent event)
    {
    String values = "[";
    for (String val: grid.getEditedRecord(0).getAttributeAsStringArray("dept"))
    {
    values += val + " ,";
    }
    values += "]";
    SC.say(values);
    }
    });
    layout.addMember(valueB);
    Last edited by rs44; 3 Aug 2017, 13:17.

    #2
    Remember to always post your product and full version, and if you aren't already testing with the latest patched version (see SmartClient.com/builds).

    You should also try removing that explicit toString() call, at least when it's not necessary (check if the value is already a String). Older versions of GWT had issues with this kind of call (see FAQ) and perhaps even if you are using a newer version, it may have been reintroduced for some cases.

    Also report your version of GWT (every time).

    Comment


      #3
      Thanks. I am using SmartGWT 6.0.20170522
      GWT 2.7.0

      I removed the toString() and it still has the same issue
      Object product = values.get("product");
      String [] depts = departments.get(product);

      for (int i = 0; i < depts.length; i++)
      {
      valueMap.put(depts[i], depts[i]);
      }

      Comment


        #4
        You should always try the latest build from smartclient.com, since new fixes for framework bugs are added into the builds we run nightly.

        In this case, this issue was fixed on August 1, so you can just update to the latest and you should see things work as you expect.

        Comment

        Working...
        X