Storing values in CMP as json, how to return the value back into the extJS window

Hi,
I’m saving multiple extJS fields values as JSON into a single table column within a customer table.

I’m doing this by using a field name array syntax within the extJS window, for example

items: [{
                xtype: 'textfield'
                ,fieldLabel: '12:00'
                ,name: 'times[12:00]'
                ,anchor: '100%' 
            }
            ,{
                xtype: 'textfield'
                ,fieldLabel: '12:15'
                ,name: 'times[12:15]'
                ,anchor: '100%' 
            }
    ]

I’m converting the array to JSON when I save and all that’s working fine.

But how can I retrieve the value when I edited the row within the CMP. Need to changed the value some how when the window opens. I’ve tried using the value property but this only works for a default value so no good when updating.

Any ideas?

As you provide very little information about your code, it is difficult to give sound advice.
But assuming you use setValues() to set the values of the window’s form, something like this might work:

this.myUpdateWindow.setValues(this.menu.record);

var times_obj = Ext.util.JSON.decode(this.menu.record.times);
this.myUpdateWindow.fp.getForm().findField('times[12:00]').setValue(times_obj['12:10']);
this.myUpdateWindow.fp.getForm().findField('times[12:15]').setValue(times_obj['12:15']);

That’s probably not the most elegant solution and maybe it’s a better idea to adjust the getlist/get processor to return every value in JSON as a separate field.

Thanks for the reply.

this.myUpdateWindow.fp.getForm().findField(‘times[12:00]’).setValue(times_obj[‘12:10’]);

This looks to be working, which is great, thanks.

But yeah agree with amending the getlist might be the better option, but was having issue targeting the multiple fields.

I’ve tried the following to trying and target one of the specific times fields with a hard coded value but no luck

public function prepareRow(xPDOObject $object) {
    $row = $object->toArray('', false, true);
    $row['times[12:00]'] = '111'; 
  //Also tried $row['times'][0] = '111';
    return $row;
}