1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    81
    Answers
    3
    Vote Rating
    0
    mice-pace is on a distinguished road

      0  

    Default Unanswered: What are the steps in binding a store to a form?

    Unanswered: What are the steps in binding a store to a form?


    Right now i'm trying to do something complicated with using a dynamic url on  a store's proxy to fetch results for different places conditionally... And i got rid of all the errors, so i *think* that's working, So right now I need to check the simple stuff, like wether the form i'm trying to dump the data into actually maps to the store.

    There's good documentation on making Store/models, and even creating views and binding them to stores. But at that point I'm out of luck. Literally the most help it could give me was 'You may further need to configure the view so that it displays data correctly. For examples of how to do that, see either Build Your First Desktop Application or Build Your First Mobile App'... Neither of which use a form that way.

    So i'm hoping someone won't mind stepping me through a checklist on the basics of joining the dots, so i can make sure i haven't missed anything

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,781
    Answers
    450
    Vote Rating
    599
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    First step is posting in the right spot! Moving to QA.

    Secondly: http://dev.sencha.com/deploy/ext-4.1...form-grid.html
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha User
    Join Date
    Apr 2012
    Posts
    81
    Answers
    3
    Vote Rating
    0
    mice-pace is on a distinguished road

      0  

    Default


    Perhaps i failed to explain, I'm not using a grid. Binding to a grid isn't as hard and is better documented, an example closer to what i'm doing would be this one:

    http://docs.sencha.com/ext-js/4-0/#!.../xml-form.html

    ...And as far as i'm aware this isn't even possible in Architect, the Reader object is passed a model and I can't find a way to do that. It could be possible, but i'm not sure how exactly

  4. #4
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,781
    Answers
    450
    Vote Rating
    599
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    No, but the grid is backed by a store, after which you can see it's calling loadRecord() on the form and passing in a model.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  5. #5
    Sencha User
    Join Date
    Apr 2012
    Posts
    81
    Answers
    3
    Vote Rating
    0
    mice-pace is on a distinguished road

      0  

    Default


    Which i'm doing. The code i wrote below (presumably) does that:

    Code:
        getJobDetails: function(jobno) {
            var job = Ext.data.StoreManager.lookup('jobStore');
            job.getProxy().url='http://dev:85/data/job.php?jobno='+jobno;
    
    
    
    
            job.load({success: function(user) {
                var data = job.first();
                Ext.getCmp('JobForm').loadRecord(data);
            }});
        }
    So right now I need to check the simple stuff
    such as wether i:
    further need to configure the view so that it displays data correctly
    I thought i had made that plain? Maybe not. Let me elaborate...

    I believe my code is already fetching a model, and sending it to the form's loadRecord method, this is giving no more javascript errors, so i assume that part is working. My guess is that the reason the data is not showing up is a difference between the fields in the form compared to the model, or the fields in the store compared to the model. Basically, i was hoping someone would mention the different steps required in making sure things line up (make sure you are using the same root, all the fields in the form have a 'name' etc...) so i can find out exactly where i need to look for discrepancies, and then narrow the problem back to my code if i can't find any anywhere else.

  6. #6
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,910
    Answers
    655
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    You will have to provide more details about your model,store ... etc. You are asking for help with little information, then asking if it is correct, but why is it not working?

    difference between the fields in the form compared to the model
    Are you mapping the fields to the alternate names?
    Have you checked the console to make sure that data is sending/receiving as expected?

    Scott.

  7. #7
    Sencha User
    Join Date
    Apr 2012
    Posts
    81
    Answers
    3
    Vote Rating
    0
    mice-pace is on a distinguished road

      0  

    Default


    You are asking for help with little information, then asking if it is correct, but why is it not working?
    Actually that's what I was trying to avoid doing *laughs*

    I was hoping to get advice on the general steps, One to narrow down the source of the problem, but more importantly Two to make sure that in a more general sense i'm doing the right things in the right order and i know what to check. I'm still new to Sencha Architect and having to take the Self-Taught route... I'm not doing badly, but a formal curriculum it is not, so the more official a word is on how to do something the better it probably is with fewer pitfalls.

    Have you checked the console to make sure that data is sending/receiving as expected?
    Actually i hadn't (didn't even know I could directly see the resturned JSON in Chrome, but i found it. Marvelous) but i just did, as i suspected (but hadn't checked) the data is being sent and looks correct to me.

    Do you want me to give specifics about the Fields and the JSON, or are you happy as the title says, just to roughly outline the steps it goes through?

  8. #8
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,910
    Answers
    655
    Vote Rating
    443
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    If you believe your JSON is correct (jsonlint.com), then you need to make sure it is formatted correctly based on your store/proxy settings. The next step would be to set a watch on your store and see if it then populating your store. If you are using Chrome, then you can use DevTools to debug your app and find out what is going on.

    In your store, you can add a listener on the load event and see if the data is making it into the store. If this not happening, then you need to determine if your JSON is incorrect, or that your store is not setup correctly.

    Code:
    listeners: {
       load: function(store){
             console.log(store); 
             console.log(store.getCount()); 
       }
    }
    Scott.

  9. #9
    Sencha User
    Join Date
    Apr 2012
    Posts
    81
    Answers
    3
    Vote Rating
    0
    mice-pace is on a distinguished road

      0  

    Default


    Correct JSON? Check.
    Store has a count on Load? Check (4)

    So i was right about not mapping the fields right then. Still i'm very glad for the other things to check, that will make it quite a lot easier in the future knowing those two checks, thanks Scott

    Back to the beginning though, what do i need to match up to what where? (I know, i could give you the code and it would be faster, but i want to learn the general principles) We've got attributes in the JSON, and we could have fields in the store and/or the model, names on form elements and columns in grids.

    The funniest thing is, when in Architect when i get the store to load the data i see it reflected in the grid, but not when i open the project up for real.
    Last edited by mice-pace; 12 Sep 2012 at 3:20 PM. Reason: minor update at end of post

Thread Participants: 2