Announcement

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

    ListGridField with setMultiple(true) sending value as Long instead of List<Long>

    SmartClient Version: v9.1p_2014-08-29/Pro Deployment (built 2014-08-29)

    Hi, I have a Listgrid with a ListGridField as follows:

    Code:
    ListGridField teams = new ListGridField("teamId", "Teams");
    teams.setOptionDataSource(teamDS);
    teams.setValueField("companyTeamId");
    teams.setDisplayField("name");
    teams.setMultiple(true);
    My problem is that there is a difference in the data being sent by the ListGrid depending on whether or not I used my mouse to select the value in the ListGridField.

    If I use my mouse to open the dropdown and select a single item from the list, then the value is a List<Long> with one element which is what I would expect.
    Code:
        data:{
            getActive:1, 
            sessionId:"78e73263-2e5b-4946-b298-97edcc2c3dee", 
            loggedInUserID:19, 
            initials:"test", 
            email:"test@gmail.com", 
            [B]teamId:[
                7
            ],[/B]
            groupId:27, 
            firstName:"njk", 
            lastName:"njk", 
            externalId:"123"
        }
    But if I instead just TAB to the field and select a value by pressing the down arrow key on my keyboard, the value of the field is a Long and not a List.

    Code:
        data:{
            getActive:1, 
            sessionId:"78e73263-2e5b-4946-b298-97edcc2c3dee", 
            loggedInUserID:19, 
            initials:"test", 
            email:"test@gmail.com", 
            [B]teamId:7,[/B]
            groupId:27, 
            firstName:"njk", 
            lastName:"njk", 
            externalId:"123"
        }
    Is this intended behavior?

    #2
    Technically, this is allowed. The saved value of a multiple:true field *as loaded from a DataSource* should always be an Array, but in general, values inbound for saving are not required to have been validated, and well-written server logic should handle singular or array.

    Also, as far as handling *criteria* against a multiple:true field, you always have to handle both the singular and array case.

    That said, it would be more convenient for various kinds of logic if the value available from the SelectItem was always an array. If you can show how this can be reproduced in the latest patched version, perhaps in a Showcase example, we'll take a look.

    Comment

    Working...
    X