Note that there are some explanatory texts on larger screens.

plurals
  1. POExt-JS 4 - strange behavior with submitting combobox to server
    primarykey
    data
    text
    <p>I have a combobox in a form:</p> <pre><code>{ xtype: 'combobox', fieldLabel: 'Jurisdictions', name: 'jurisdiction_id', id: 'ComboboxJurisdictions', store: Ext.create('App.store.Jurisdictions'), queryMode: 'local', editable: false, displayField: 'name', valueField: 'id', } </code></pre> <p>Data is:</p> <pre><code>1 =&gt; Administrator 2 =&gt; User 3 =&gt; Guest </code></pre> <p>Now, if I don't touch anything when editing a user, on my server for my combobox I get "Administrator" (displayField), but when I change something in combobox I get the "id" (valueField). I really just want "id" in both cases. I was reading about <code>hiddenName</code>? Is that the case?</p> <p>If you need any more code, feel free to ask. :)</p> <p>Thank you!</p> <p>EDIT (more code)</p> <p>1.) There is no default value.</p> <p>Here is the whole view code:</p> <pre><code>Ext.define('App.view.Suits.Update', { extend: 'Ext.window.Window', title: 'Suits', width: 250, id: 'UpdateWindowSuits', defaultType: 'textfield', items: [{ xtype: 'UpdateFormSuits' }], buttons: [ { text: 'Save', id: 'submitUpdateFormButtonSuits'}, { text: 'Cancel', id: 'cancelUpdateFormButtonSuits'}, ] }); Ext.define('App.view.Suits.UpdateForm', { extend: 'Ext.form.Panel', alias: 'widget.UpdateFormSuits', layout: 'form', id: 'UpdateFormSuits', bodyPadding: 5, defaultType: 'textfield', items: [{ fieldLabel: 'Id', name: 'id', hidden: true },{ fieldLabel: 'Name', name: 'name', allowBlank: false, },{ fieldLabel: 'Status', name: 'status', allowBlank: false },{ xtype: 'combobox', fieldLabel: 'Priority', name: 'suit_priority_id', id: 'ComboboxSuitPriorities', store: Ext.create('App.store.SuitPriorities'), editable: false, displayField: 'name', hiddenName: 'id', valueField: 'id' },{ xtype: 'combobox', fieldLabel: 'Jurisdictions', name: 'jurisdiction_id', id: 'ComboboxJurisdictions', store: Ext.create('App.store.Jurisdictions'), queryMode: 'local', editable: false, displayField: 'name', valueField: 'id', }], }); </code></pre> <p>Here is the store:</p> <pre><code>Ext.define('App.store.SuitPriorities', { extend: 'Ext.data.Store', // Where is the Model. model: 'App.model.SuitPriority', // "id" of the Store. storeId: 'SuitPriorities', // Autoload all data on creation. autoLoad: true, // Number of records in one page (for pagination). pagesize: 20, // Proxy for CRUD. proxy: { // Type of request. type: 'ajax', // API for CRUD. api: { create : 'php/suitpriorities/update', read : 'php/suitpriorities/read', update : 'php/suitpriorities/update', destroy : 'php/suitpriorities/delete' }, // Type of methods. actionMethods: { create : 'POST', read : 'POST', update : 'POST', destroy : 'POST' }, // Reader. reader: { // Which type will the reader read. type: 'json', // Root of the data. root: 'suitpriorities', rootProperty: 'data', // One record. record: 'SuitPriority', // Message and success property. successProperty: 'success', messageProperty: 'message' }, // Writer (when sending data). writer: { type: 'json', writeAllFields: true, root: 'data', encode: true }, }); </code></pre> <p>As I sad, the store is getting all the data because it's already loaded when I press the combobox. It's a simple JSON with 'id' and 'name' properties.</p> <p>EDIT2: I've tried this for my Jurisdictions because I wasn't getting the right data selected in combobox. This is inside my controller.</p> <pre><code>onJurisdictionComboRender: function(combobox, eOpts){ // Getting the selected row. var record = this.grid.getSelectionModel().getSelection()[0]; // Selected jurisdiction. var jurisdiction = record.data.jurisdiction_id; // Select it in combobox. combobox.select(jurisdiction); } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload