[CLOSED] Posting Store Records - new records also picked up in modified collection

  1. #1

    [CLOSED] Posting Store Records - new records also picked up in modified collection

    Hi
    I have 3 stores which I submit to my controller thus:

    <ext:Parameter Name="modifiedAccounts" Value="Ext.encode(getModifiedStoreData(individualAccountsStore.getModifiedRecords()))" Mode="Raw" />
    <ext:Parameter Name="modifiedEmails" Value="Ext.encode(getModifiedStoreData(emailAddressesStore.getModifiedRecords()))" Mode="Raw" />
    <ext:Parameter Name="modifiedPhoneNos" Value="Ext.encode(getModifiedStoreData(phoneNosStore.getModifiedRecords()))" Mode="Raw" />
    <ext:Parameter Name="createdAccounts" Value="Ext.encode(getNewStoreData(individualAccountsStore.queryBy(function(r){return r.newRecord;})))" Mode="Raw" />
    <ext:Parameter Name="createdEmails" Value="Ext.encode(getNewStoreData(emailAddressesStore.queryBy(function(r){return r.newRecord;})))" Mode="Raw" />
    <ext:Parameter Name="createdPhoneNos" Value="Ext.encode(getNewStoreData(phoneNosStore.queryBy(function(r){return r.newRecord;})))" Mode="Raw" />
    <ext:Parameter Name="deletedAccounts" Value="Ext.encode(getModifiedStoreData(individualAccountsStore.deleted))" Mode="Raw" />
    <ext:Parameter Name="deletedEmails" Value="Ext.encode(getModifiedStoreData(emailAddressesStore.deleted))" Mode="Raw" />
    <ext:Parameter Name="deletedPhoneNos" Value="Ext.encode(getModifiedStoreData(phoneNosStore.deleted))" Mode="Raw" />
    I note that new records picked up via, for example emailAddressesStore.queryBy(function(r){return r.newRecord;}), are also present in the emailAddressesStore.getModifiedRecords() collection. Both collections hold the most up to date version. I can filter out new records via isNew() on the client side. However, can you confirm if new records are supposed to be included in both collections, as it does seem rather counter intuitive?

    regards
    Last edited by Daniil; Jun 27, 2011 at 12:33 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Yes, new records are included into returned by .getModifiedRecods() collection.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    Yes, new records are included into returned by .getModifiedRecods() collection.
    I've noticed this as well actually. Can you explain why this is done? It seems redundant to have the record shown in both locations as it then requires a further level of filtering to remove the duplicate records from the modified collection, so as not to duplicate work of saving records that've already been added.

    Also, deleted rows don't seem to show up in the modified collection; this seems inconsistent with added records.

    Thanks.
  4. #4
    Quote Originally Posted by peter.campbell View Post
    I've noticed this as well actually. Can you explain why this is done?
    Well, the creators of the Store class decided that it's the best way.

    For modified records (updated and new) the store's .modified array is used.
    For deleted records the store's .deleted array is used.

    Quote Originally Posted by peter.campbell View Post
    It seems redundant to have the record shown in both locations as it then requires a further level of filtering to remove the duplicate records from the modified collection, so as not to duplicate work of saving records that've already been added.
    Can you clarify which two locations are you talking about? And where do you see redundant?

    Quote Originally Posted by peter.campbell View Post
    Also, deleted rows don't seem to show up in the modified collection; this seems inconsistent with added records.
    Why is it inconsistent?

    For me it's fine that deleted records are separated from updated and new ones.
  5. #5
    Both locations as in updated and inserted. Redundant because its the same record in both locations. It's fair enough if that's 'just the way it is' I wondered though if there was some definitive reason for this you were aware of.

    It seems inconsistent because an inserted record is flagged as modified; but a deleted one is not.

    Thanks.
  6. #6
    Quote Originally Posted by peter.campbell View Post
    Both locations as in updated and inserted. Redundant because its the same record in both locations.
    I don't know these locations - updated and inserted. I know only one - store.modified.

    Quote Originally Posted by peter.campbell View Post
    It seems inconsistent because an inserted record is flagged as modified; but a deleted one is not.
    Well, I think, they are not the same - inserted and deleted records. I don't think that a deleted record should be marked as modified.

    I'd suggest you to investigate the Store's .getChangedData() function. Maybe it will shed some light on this.

Similar Threads

  1. Replies: 4
    Last Post: Jun 08, 2012, 10:05 AM
  2. [CLOSED] Modified records in store get purged prior to BeforeLoad event
    By Mark.Cooke in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 20, 2010, 7:08 PM
  3. Get Store records
    By walle in forum 1.x Help
    Replies: 4
    Last Post: Jul 17, 2010, 5:19 PM
  4. Replies: 3
    Last Post: Jun 29, 2010, 2:54 PM
  5. [CLOSED] Added Records don't show up as modified
    By Dave.Sanders in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 21, 2008, 6:54 AM

Posting Permissions