PDA

View Full Version : Dynamically set valueFIeld/displayField in Ext.ux.form.MultiSelect



hcallesis
6 May 2020, 10:45 AM
I'm using Sencha Architect 4.2.8 and ExtJS framework 7.2.0. I've created a form which includes a MultiSelect and a few buttons. The intent is that when I instantiate this form it would be assigning a different store (with different field names) to the MultiSelect, allowing the same basic set of functions to work on multiple stores as needed without duplicating the interface for each store. In testing, when I assign valueFIeld and displayField to field names associated with the test store (which is assigned via setStore()) in Architect, the form works as intended. However, when I clear those fields in Architect and attempt to set them at runtime, it doesn't work. I set them before loading the store each time, and before calling show() on the parent window. I've tried setting them directly and with setConfig(), I've tried setting them in a beforeRender event, with and without setConfig(). There are no setDIsplayField or setValueField methods to use. I've looked online for examples of setting valueField and displayField dynamically, but I can only find examples using combobox, which doesn't help. So my question is, is there a way to dynamically set valueFIeld and displayField at runtime in Ext.ux.form.MultiSelect?

hcallesis
11 May 2020, 8:00 AM
I'm using Sencha Architect 4.2.8 and ExtJS framework 7.2.0. I've created a form which includes a MultiSelect and a few buttons. The intent is that when I instantiate this form it would be assigning a different store (with different field names) to the MultiSelect, allowing the same basic set of functions to work on multiple stores as needed without duplicating the interface for each store. In testing, when I assign valueFIeld and displayField to field names associated with the test store (which is assigned via setStore()) in Architect, the form works as intended. However, when I clear those fields in Architect and attempt to set them at runtime, it doesn't work. I set them before loading the store each time, and before calling show() on the parent window. I've tried setting them directly and with setConfig(), I've tried setting them in a beforeRender event, with and without setConfig(). There are no setDIsplayField or setValueField methods to use. I've looked online for examples of setting valueField and displayField dynamically, but I can only find examples using combobox, which doesn't help. So my question is, is there a way to dynamically set valueFIeld and displayField at runtime in Ext.ux.form.MultiSelect?

I figured out a way. I define a constructor for the window, and pass in a config object {valueField: 'x', displayField: 'y'}, Inside the constructor I parse the items list looking for reference = 'referencename' (a loop because lookup isn't configured yet), then call Ext.apply(list, config) and call the parent constructor (me.callParent(arguments). Kind of a roundabout solution but it works, I can set the value/display fields at the time I instantiate the window at runtime.