Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>When the server side is the one setting the id, the workflow is this:</p> <ul> <li>Record added to the store without an id being assigned.</li> <li>Store syncs, so a Create request is being sent to the server.</li> <li>Server returns the sent record, with an id property set.</li> <li>ExtJS looks at the returned record and if it has an id set, it assignes it to the record.</li> </ul> <p>Notice, by the way, that for all CRUD operations, the store record will be updated with the data returned from the server so long the id matches. In the case of newly created records, ExtJS has an internalId mechanism to determine that the record returned is the one sent, but with its id set.</p> <p>The server side code might look something like this:</p> <pre><code>function Create( $aRecord ) { global $pdo; $iInsertClause = InsertClause::FromFields( self::$persistents ); $iStatement = $pdo-&gt;prepare( "INSERT INTO Tags $iInsertClause" ); $iStatement-&gt;execute( InsertClause::ObjectToParams( $aRecord, self::$persistents ) ); // Inject the id into the record and return it in the reader's root, // so client side record updates with the new id. $aRecord-&gt;id = $pdo-&gt;lastInsertId(); return array( 'success' =&gt; true, 'data' =&gt; $aRecord, ); } </code></pre> <p>Then within your app, your controller should hook on store write events. Something like this:</p> <pre><code>init: function() { this.getTasksStore().on({ write: this.onStoreWrite, scope: this }); }, </code></pre> <p>And within that function you can inspect the returned record (I assume <code>data</code> is the reader's root):</p> <pre><code>onStoreWrite: function ( aStore, aOperation ) { var iRecord = aOperation.response.result.data; console.log(iRecord.id); }, </code></pre>
    singulars
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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