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

  • Displaying multi-select option's text


    We use GWT 2.8.1 with SmartGWT 6.1.

    We have a requirement in which we need an editor on a text field of a ListGrid.
    In that editor, we have a grid with multi select columns(3 columns : ID - acts as option value/code&description - As Option display text).
    The requirement is that as soon as user selects some values from drop down, the corresponding code value should be shown in the ListGrid fields as comma seperated string.

    Currently the field displays the value as comma seperated IDs of the selected list grid rows, which comes out from a summaryFunction.
    We can make code field as option/display value for the multi select drop down editor but the code column is not unique.
    Therefore we will not be able to select the corresponding row again in the editor or show the selected values as per the unique values.

    Is there any way so that we can achieve the showing display value as code and handling the selection logic in the grid through row IDs ?

    Thanks ,

  • #2
    This post is very vague - you haven't really explained the data model here, and it's not clear what you expect to be stored in the editor.

    Our best guess is that you may be talking about a SelectItem with an optionDataSource, and the records being returned by the optionDataSource aren't singular database records, but instead the result of a SQL group by (using our summaryFunction feature). Or maybe the records are singular database records, but one column is a summaryFunction of other related records.

    With what you've explained so far, all we can say is that if you think there are internal row IDs in the framework, separate from any primary keys that you might have declared, these do not exist, so no, there wouldn't be a way to handle this via row IDs. A SelectItem using an optionDataSource requires that the values for the valueField are unique per record, or it cannot work.


    • #3

      We have tried the same that we have a select Item with a display field which is description which is not unique.
      But we want the ID related to that record to be sent at backend but at UI side , the description should be used for display.

      Is there any other posssible workaround for this or any customization possible with the current framework?


      • #4
        Your first post was quite vague and this follow-up is even more so. If you want to make it possible to help you, please explain the data model and the controls involved, at a minimum.


        • #5

          This is the select Item we are creating as when we click on the field say 'A' of our grid

          final SelectItem attrItem = new SelectItem();
          final DataSource productLineAttrDataSource = DataSource.get(ClientConstants.HARDWARE_ATTRIBUTES_DS);
          final ListGrid userSelectProperties = new ListGrid();

          ListGridField attributeDescField = new ListGridField(ATTRIBUTE_DESCRIPTION_FIELD);
          ListGridField printCodeField = new ListGridField(HARDWARE_ATTR_DS_PRINT_CODE,
          ListGridField printDescriptionField = new ListGridField(HARDWARE_ATTR_DS_PRINT_DESCRIPTION,

          String hardwareLineId = context.getEditedRecord().getAttribute("hardwareLineId");
          final Criteria criteria = new Criteria();
          criteria.addCriteria(ClientConstants.PRICEBOOK_ID, priceBookId);
          criteria.addCriteria("hardwareLineId", hardwareLineId);

          attrItem.setPickListFields(attributeDescField, printCodeField, printDescriptionField);
          return attrItem;

          And the field of the main grid is populated using a native query which has a group_concat(IDS) sort of fetch criteria.

          Now the field is showing IDS , but the select item which opens up on editor of that field has three fields description,print_code and print_description
          here description is not unique

          So when we click on the row of this grid which opens up as select Item , it appends the ID related to that record in the grid field 'A' like ID1,ID2,ID3 etc

          So what is required is can we display the description instead of ID here in that field?


          • #6
            Still not clear what you mean - is this SelectItem configured as the editor of the ListGridField via editorProperties?

            A SelectItem will look up and display values for the displayField using it's optionDataSource. Above, you've configured the valueField and displayField as the same field, so of course the IDs would be shown - you haven't told the SelectItem to do anything else.

            One more point of failure - group_concat() would generally produce a singular string value - a concatenated string representing values from several rows. Make sure you have server-side code that converts this to an Array of String before you return the response to the client. An Array of String is the expected value for a field that is marked multiple:true, and if you return the value as a single string, that's invalid and won't work.


            • #7
              Yes , the select item opens up on editor of the ListGrid Field and yes , we are processing the string coming from group_concat function into a string array
              So as u said that since the displayField and vlaueField is ID , it will display only ID.
              And if description has to be shown on the grid field value , then either that has to be set as displayField of the select Item and then the uniqueness of that description should be maintained.

              Please confirm if this is rightly understood.


              • #8
                See docs for selectItem.displayField - uniqueness is not required for correct operation, but a lack of uniqueness could be confusing for your users, since with the pickList closed, the description does not uniquely identify a record. However internally, so long as IDs are unique (which is required), the SelectItem itself will not be confused about which records the user has chosen, since it keeps IDs.

                If you really want to show the description to the user, you might use a ValueFormatter to *also* show the ID. There are samples showing this approach (for a singular select, but it's the same) in the Showcase.