1. #1
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    0
    kalor is on a distinguished road

      0  

    Default Unanswered: FormPanel: accessing the data object

    Unanswered: FormPanel: accessing the data object


    Hi guys,

    I'm new to sensha and to some extent js. I've created a test app with list and detail forms, pretty standard stuff I guess. Here's my list definition:

    Code:
           MyApp.views.requestsList = new Ext.List({
                id: 'requestsList',
                store: 'RequestJobStore',
                onItemDisclosure: function (record) 
                {
                    var selectedJob = record;
                    MyApp.views.JobEditor.load(selectedJob);
                    MyApp.views.viewport.setActiveItem('JobEditor', { type: 'slide', direction: 'left' });
                },
                itemTpl: '<div class="list-item-title">{Name}</div><div class="list-item-jobfield">{Company}</div>',
                listeners: {
                    'render': function (thisComponent) {
                        thisComponent.getStore().load();
                    }
                }
            });
    You can see that the selectedJob is passed to the JobEditor.

    Now the JobEditor displays some of the fields in the Job data object. In the JobEditor's code I know I can get the value of these by

    Code:
    MyApp.views.JobEditor.getValues().FieldName
    What I want to know is, how can I get the value of the other fields? The fields in the JSON object passed to the FormPanel, that do not have textfields?

    I'm hoping I don't have to resort to dodgy invisible textfields or something. Not that I know how to do that either. Can anyone advise me please?

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Answers
    3356
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I would use setRecord on the form and pass the record that was tapped on. You can then use updateRecord when you save the form and getRecord to get the record.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Hi kalor.
    As you said, getValues() returns an object containing the value of each field in the form, so if you don't have a field associated to the field values that you want to retrieve, you are not able to do that in that way.

    However, I suggest you to use "hiddenfield" to contains the values of those fields that you don't want to show on your form, but that you still want to be able to get their values using the "getValues" function.

    Hope this helps
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Answers
    3356
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by andreacammarata View Post
    Hi kalor.
    As you said, getValues() returns an object containing the value of each field in the form, so if you don't have a field associated to the field values that you want to retrieve, you are not able to do that in that way.

    However, I suggest you to use "hiddenfield" to contains the values of those fields that you don't want to show on your form, but that you still want to be able to get their values using the "getValues" function.

    Hope this helps
    That's messy and unneeded DOM elements. Using the built in functions to work with records is better.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    That's messy and unneeded DOM elements. Using the built in functions to work with records is better.
    I agree, but we don't know his application architecture, so he probably need to save the record inside the controller, and when he need to get all the complete record data (the one edited by the form and the one not visible inside the form), should merge the one retrieved by calling the "form.getValues() function" with the one stored inside the saved record.
    However I agree on the fact that keeping the DOM clear on mobile apps has to be a priority.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Answers
    3356
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by andreacammarata View Post
    I agree, but we don't know his application architecture, so he probably need to save the record inside the controller, and when he need to get all the complete record data (the one edited by the form and the one not visible inside the form), should merge the one retrieved by calling the "form.getValues() function" with the one stored inside the saved record.
    However I agree on the fact that keeping the DOM clear on mobile apps has to be a priority.
    So let's coach him the better way since he is already going to have a record from the list.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User
    Join Date
    Nov 2011
    Posts
    72
    Answers
    3
    Vote Rating
    0
    kalor is on a distinguished road

      0  

    Default


    OK I think I have the record, but I don't know the syntax to use it. I thought I'd be able to use record.fields[0] or record.CompanyName or something. How do I get the value of a specific field?

  8. #8
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Answers
    148
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    If your record has a CompanyName field, that you just need to call

    Code:
    record.get('CompanyName');
    http://docs.sencha.com/touch/2-0/#!/...del-method-get

    In the same way, if you have to set a field value, just call

    Code:
    record.set('CompanyName', 'My Company Name');
    http://docs.sencha.com/touch/2-0/#!/api/Ext.data.Model-method-set

    Hope this helps.
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar