Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking sure an ExtJS checkboxfield updates its model
    primarykey
    data
    text
    <p>I have inherited an ExtJs4 project, and I've got a fairly basic question.</p> <p>I have a view that has a newly added checkbox field as one of the items, like so:</p> <pre><code>{ boxLabel: 'Test Message?', xtype: 'checkboxfield', id: 'cbTextMessage', checked: false, name: 'testMessage', inputValue: true, uncheckedValue: false } </code></pre> <p>When the record is active, this value changes to the appropriate checked or unchecked state. When creating a new record, the value is set to the value of the checkbox. However, when editing an existing record, the model never gets updated to any value other than the original value.</p> <p>The model:</p> <pre><code>Ext.define('PushAdmin.model.Message', { extend: 'Ext.data.Model', idProperty: 'id', requires: ['Proxy.ParameterProxy'], fields: [ { name: 'id', type: 'int' }, { name: 'games', type: 'auto', convert: function(data, model) { data = ( data &amp;&amp; !Ext.isArray(data) ) ? [data] : data; return data; } }, { name: 'msgEnglish', type: 'string' }, { name: 'msgFrench', type: 'string' }, { name: 'msgSpanish', type: 'string' }, { name: 'testMessage', type: 'bool' }, { name: 'sendAt', type: 'date' }, { name: 'note', type: 'string'}, { name: 'status', type: 'string' }, ], proxy: { type: 'rest', url: '/apnsadmin/rest/Message', pageParam: undefined, startParam: undefined, limitParam: undefined, reader: { type: 'json', root: 'data', successProperty: 'success' } } }); </code></pre> <p>And finally this is the function that gets called when the save button is clicked.</p> <pre><code>click: function () { var grid = this.getQueuedMessagesGrid(); var sm = grid.getSelectionModel(); var selectedRecord = sm.getCount() &gt; 0 ? sm.getSelection()[0] : undefined; this.getMessageForm().getForm().updateRecord(); var newRecord = this.getMessageForm().getForm().getRecord(); if (selectedRecord!=undefined) { console.log(selectedRecord); console.log(newRecord); selectedRecord.save(); } else { // New record! console.log("Saving new record"); grid.getStore().add(newRecord); newRecord.save(); } this.getMessageForm().setDisabled(true); this.getMessageForm().getForm().reset(); } }, </code></pre> <p>I am aware that things are probably not the proper ExtJS way to do things, but since this is mostly working I am trying not to have to rewrite large chunks of it. I'd just like to know what I'm doing wrong in adding this checkbox/boolean field to the form.</p>
    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.
    1. This table or related slice is empty.
    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