How to connect a selectItem to data in the record

We have a ListGrid with editable rows. One column needs to be editable as a selectItem. I see many examples of using optionDataSource to point to a DataSource for the list items. How an I just use an array present in the record as the valueMap? For example, if the json for the record is something like:

([{“ROWID”:0,“AVAILABLE”:8,“SHIP_FROM_ORG_ID”:“84”,“SHIPPING_METHODS”:{“2”:“Best Way-LTL-Ground”,“3”:“INTERORG-TL-Ground”}}])

Where shipping methods is an array, how do I make the select item come up with those choices? Is that possible?

Thanks
Pete

Sure, use getEditorValueMap().

Thanks, that works good. We now use this to populate the select:

            getEditorValueMap: function(field, values) {
                if (field.name == "SHIPPING_METHOD") {
                    return this.getSelectedRecord().SHIPPING_METHODS;
                }
            },

Interestingly, the “values” argument doesn’t contain the entire record being edited, only the first column (which in our case is a fields called ROWID). This requires the use of setSelectedRecord() to fetch the shipping methods valueset instead of being able to return values.SHIPPING_METHODS.

However, when the ListGrid is first drawn, the column contains the numeric value that comes in the record as SHIPPING_METHOD. Is there a way to apply a valuemap that’s in the record in the ListGridField directly so it maps during creation?

I’ve tried doing:

[CODE
getCellValue: function(record, recordNum, fieldNum) {

            if (fieldNum == 4) {
                return record.SHIPPING_METHODS[record.SHIPPING_METHOD];
            }

            return this.Super("getCellValue", arguments);
        },


This causes the field to show the mapped value, but also for some reason causes the field to no longer be editable (ignores the canEdit: true).

Thanks for any insight you can provide on this one.

Hi Pallen,

There are a few approaches covered in the docs for ListGridField. It looks like you may be able to just set displayField on the “SHIPPING_METHOD” field to “SHIPPING_METHODS”.