1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    69
    Vote Rating
    2
    deshartman is on a distinguished road

      0  

    Default Master/Detail & Add/Save/Edit best practises

    Master/Detail & Add/Save/Edit best practises


    I am building a simple Master/Detail app.
    The master view is a list of records & an Add button.
    When clicking on the list Item I display the detail view. If you change any item in the detail view I show a save button.
    If you click the Add button on the Master view I show an empty detail panel and a save button.


    All of this is pretty straight forward, but I am stuggling to find a decent Architect 2 MVC example, showing how to do this. All the examples like CityBars and AddressBook, either do not edit the data or do not follow MVC rules.

    Does anybody have a Touch 2 MVC based example of how to do this?

    Concepts I am struggling with are:

    1) What is the best way to pass the Master record to the detail view? Do I use a store, do I use data.

    2) How do I code the Save button to call a function on the master to update the edited or added record? I do not want the detail view's controller to have to deal with saving the record in the store? I thought a callback to the master may work, but do not know how I pass a callback function to the detail controller.

    Thanks
    Des

  2. #2
    Sencha - Architect Dev Team aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,365
    Vote Rating
    128
    aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold aconran is a splendid one to behold

      0  

    Default


    Des -

    Good question! Luca Candela and I presented a session today at SourceDevCon that went over creating a basic CRUD view with adding and updating.

    You can check out the repo here:

    https://github.com/CaliLuke/NativeContacts
    Aaron Conran
    @aconran
    Sencha Architect Development Team

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Location
    Mercer Island, WA
    Posts
    66
    Vote Rating
    0
    DonRul is on a distinguished road

      0  

    Default


    That is very helpful for a single-table app but doesn't help much with the Master-Detail question. I am confused myself how Associations are used (confused that they are applied to models not stores). A simple multi-table example would be really helpful.

  4. #4
    Sencha User
    Join Date
    Feb 2012
    Posts
    69
    Vote Rating
    2
    deshartman is on a distinguished road

      0  

    Default


    Aaron,

    I worked through your example, but I must admit I am still having hassles with some core concepts. I have created a simpler version of the Master Detail idea and was wondering if you can help me out with a few key concepts?

    Please see attached project.

    Items that I am stuck on:

    1) Setting the title of the detail view

    There seems to be no way to set it with setTitle(). Only way I have found that works is

    Code:
    this.getMasterDetailNavgatorView().push({        
            xtype: 'detailView',
            title: 'Detail',
            data: record.data
        });
    Although I have no issue with this approach, it just seems UN-class-like. I would have expected to be able to do something like this:

    Code:
    var detail = this.getDetailView();
    detail.setTitle("Detail Title");
    detail.setData(record.data);
    this.getMasterDetailNavgatorView().push(detailView);
    the second approach makes more sense, but does not work.

    2) Setting the data values of the field list.

    Using the above code I believe I am setting the values of the fieldSet, but nothing shows up. It appears to be the same as the examples I have seen, but no luck.




    Would appreciate any help you can give in building up this example. Quite willing to document my findings and the example for the Sencha Learn part of the documentation if I can figure it out.

    Thanks
    Des
    Attached Files

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    25
    Vote Rating
    0
    sapkalparag is on a distinguished road

      0  

    Default


    Try this

    http://miamicoder.com/2012/how-to-cr...-2-app-part-1/

    same as what you want....but this is not for architect though.