[CLOSED] Multiple Stores - design pattern required

  1. #1

    [CLOSED] Multiple Stores - design pattern required

    Hi

    I have a page that formulates quotes - its quite detailed and there is a lot of calculation done along with a lot of data being updated passed around from one grid to the next etc etc. The page itself uses grid and the bryntum gant control (in all 9 writable stores ) and nothing is persisted until the 'save' button is clicked ie (autosync is off).



    In development its been ok and I have been getting this to save generally well but now that I am in testing, users have been having problems saving. The big issue is that its all in javascript and once an error is hit there is no coming back so I have some unhappy users. Because my users are all around the country it hasn't been easy tracking what is causing the mis-saves.

    So to try and simplify things I am going to modify the save mechanism. Currently my save works like this:

    - Each grid or control has its own javascript controller.
    - When a user saves it starts at the top controller i.e. Estimate and that performs a save via a DirectMethod when the onsuccess fires I go to the next controller and perform any updates on the grid that are necessary i.e child records may need the EstimateId generated from the db. I go from each controller performing the save and then updating any child records before saving them.

    I now want to change it so that I have one controller that collects all the data in one dataset and pass it all back to one DirectMethod. I will perform each object save and perform all the updates serverside.

    This I think will keep it much cleaner plus I can implement some transaction/rollback scenario should something fail. Once I have done the save I now just need to get all the information back into the stores/grids with any new Id's issued by the db as well as foreign key Ids that need to be updated.

    Any suggestions on how I do that? Can I pass data back somehow that will merge record information if it has changed? Much like when you add records back into e.ResponseRecords on BeforeChanged event of the store? (What is being called when records are written back to ResponseRecords?)

    Or can you think of a more elegant way on which this could be done?

    Thanks for any help
    Attached Thumbnails Click image for larger version. 

Name:	save.jpg 
Views:	50 
Size:	106.5 KB 
ID:	15922  
    Last edited by Daniil; Nov 07, 2014 at 11:42 AM. Reason: [CLOSED]
  2. #2
    Hi @glenh,

    Needs some time to read thoroughly, comprehend and think about.
  3. #3
    Hi Danill

    Ok I've figured out that the code that I was after that updates the stores after a beforestorechange exists in the Ext.data.Operation class in method .commitRecords. I now realise that are up to 3 operation calls made, one for reach action (create/update/delete).

    The update uses clientId to find the record and update and then commit. Delete requires no action and the create assumes records returned are in the same order to perform the lookup/commit. This is the reason why there are multiple calls made and not just one.

    I'm not sure how I can acheive what I need to (save all in one go) and I don't expect you too know this either as the stores aren't reallly designed to work this way. However, if you do come up with a theory Ill be happy to listen.

    Thanks
    Glen
  4. #4
    The big issue is that its all in javascript and once an error is hit there is no coming back so I have some unhappy users.
    Maybe, you could catch such the situation and handle in a proper way? Though, I guess it might be quite complicated.

    I now want to change it so that I have one controller that collects all the data in one dataset and pass it all back to one DirectMethod. I will perform each object save and perform all the updates serverside.
    Yes, it sounds really good. I don't think there is a better solution for your scenario.

    I'm not sure how I can acheive what I need to (save all in one go) and I don't expect you too know this either as the stores aren't reallly designed to work this way. However, if you do come up with a theory Ill be happy to listen.
    First of all, it is definitely possible:)

    Please look at this example.
    https://examples2.ext.net/#/GridPanel/Update/Batch/

    You can send the changed data of multiple Stores like this.
    <ExtraParams>
        <ext:Parameter Name="data1" Value="App.Store1.getChangedData()" Mode="Raw" Encode="true" />
        <ext:Parameter Name="data2" Value="App.Store2.getChangedData()" Mode="Raw" Encode="true" />
        <ext:Parameter Name="data3" Value="App.Store3.getChangedData()" Mode="Raw" Encode="true" />
        ...
    </ExtraParams>
    On server side you can associate each data set "data1", "data2", etc. to respective Store.

    Does that sound like a theory that you could try to implement?:) Honestly, I guess you will implement it without any problem.

Similar Threads

  1. [CLOSED] Is there a way to merge stores from multiple sources?
    By michaeld in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: Sep 12, 2013, 7:32 AM
  2. [CLOSED] Help required - Add Tab and Close Tab design architecture
    By mohan.bizbites in forum 2.x Legacy Premium Help
    Replies: 8
    Last Post: Aug 20, 2013, 4:42 AM
  3. [CLOSED] Submitting deleted records from multiple stores
    By GLD in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jun 08, 2011, 11:04 AM
  4. Newbies - How to display Coolite on design pattern
    By phancongphuoc in forum 1.x Help
    Replies: 1
    Last Post: Mar 17, 2010, 11:26 AM
  5. Updating multiple grids on save - need design pattern
    By Steve in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jan 23, 2009, 4:57 AM

Posting Permissions