1. #1
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default Answered: Big problem -> load data to form width dynamic selectfield

    Answered: Big problem -> load data to form width dynamic selectfield


    I have a big problem, I have to use Ext.Function.defer (function () {...}); to delay the loading of dynamic selectfield
    jet or some other method to load the data after loading all the stories selectfield ???????

    Please HELP!


    PHP Code:
    Ext.define('SIMOBILE.view.Edition', {
        
    extend'Ext.tab.Panel',    
        
    xtype'edition',
        
    config: {
            
    myidnull,
            
    mytypenull,
            
    ui'dark',
            
    tabBarPosition'top',
            
    tabBar: {
                
    layout: {
                    
    pack'center'
                
    }
            },        
            
    activeTab:0
        
    },    
        
    constructor: function(config) {
            var 
    me this;  
            var 
    xItems = {
                
    items: [
                {
                    
    titlelangX.xGeneral,
                    
    xtype'formpanel',
                    
    layout: {
                        
    type 'vbox',
                        
    align'stretch'
                    
    },               
                    
    items: [
                    {
                        
    xtype'fieldset',
                        
    titlelangX.xClientInformation,
                        
    defaults: {
                            
    required  true,
                            
    labelAlign'left',
                            
    labelWidth'30%'
                        
    },
                        
    items: [               
                    {
                        
    xtype'fieldset',
                        
    titlelangX.xInvoiceInformation,
                        
    defaults: {
                            
    required  true,
                            
    labelAlign'left',
                            
    labelWidth'30%'
                        
    },
                        
    items: [
                        {
                            
    xtype'textfield',
                            
    name'title',
                            
    labellangX.xTitle
                        
    },                     
                        {
                            
    xtype'selectfield',
                            
    name 'currency',
                            
    labellangX.xCurrency,
                            
    placeHolder'Select...',
                            
    valueField 'currency_id',
                            
    displayField 'currency_name',
                            
    storeExt.create('SIMOBILE.store.Currency', {})
                        },                        

                        {
                            
    xtype'selectfield',
                            
    name 'account_id',
                            
    labellangX.xAccount,
                            
    placeHolder'Select...',
                            
    valueField 'account_id',
                            
    displayField 'account_title',
                            
    storeExt.create('SIMOBILE.store.Account', {})
                        }                        
                        ]
                    }               
                    ]
                }
                ]            
            };
            
            
    config Ext.apply(xItemsconfig);
            
    me.callParent([config]);
        },  
        
        
    updateData: function(newData) {

            var 
    me this;
            var 
    me.down('formpanel');
            var 
    x.getFields();
           
            
            
    me.setMask({
                
    messagelangX.xLoading
            
    });

            
    Ext.Ajax.request({
                
    url'/route.php?params='+this.getMytype()+'/id/'+this.getMyid(),
                
    actionMethods'POST',
                
    scope:this,
                
    success: function(ro) {

                    var 
    datax Ext.JSON.decode(r.responseText);
                    
                    
    Ext.Function.defer(function(){

                        
                        
    x.loadModel(
                            
    Ext.create('SIMOBILE.model.Edition', {
                                
    'currency'datax.currency_id,
                                
    'title'datax.bill_title,
                                
    'account_id'datax.bill_account
                            
    }
                            ));
                        
    me.unmask();       
                        
                    }, 
    1500); 
                    
                        
                },
                
    failure:  function(r,o) {
                    
    me.unmask();
                }            
            });

        }
      
    }); 

  2. What I would do is load the store of the dynamic selectfield, then when it is loaded, set the value of the field with the new correct value you got from the Ajax request.

    Code:
    //load data
    var data = {fieldValue: 1};
    //create a field
    field = Ext.create('Ext.field.Select', ...);
    //load the store with a callback
    field.getStore().load(function() {
        field.setValue(data.fieldValue);
    });
    Sorry if I am not understanding you..

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,408
    Answers
    3549
    Vote Rating
    851
    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


    So you need to use loadRecord on the form after the store of a selectfield is finished loading?
    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.

  4. #3
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default


    Hey,
    I want to change value of dynamic select field,
    and I can change only after everything is loaded in a form

    an idea - an example?

  5. #4
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    You mean, you want to load the store that is binded to the Select field? If so, you will need to make another Ajax request and call the Ext.field.Select#setStore method and then call the Ext.field.Select#setValue.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  6. #5
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default


    task:
    1) I have a list and I want to modify the record
    2) I click - convey to the form id
    3) generates a field in a form (for example, I have 3 selectfield field type - for which data are retrieved [options] - using ajax store)

    PHP Code:
                        {
                            
    xtype'selectfield',
                            
    name 'currency',
                            
    labellangX.xCurrency,
                            
    placeHolder'Select...',
                            
    valueField 'currency_id',
                            
    displayField 'currency_name',
                            
    storeExt.create('SIMOBILE.store.Currency', {})
                        }, 
    PHP Code:
    Ext.define('SIMOBILE.model.Currency', {
        
    extend'Ext.data.Model',
        
    myidnull,
        
    fields: [        
        {
            
    name'currency_id'
            
    type'int'
        
    },
        {
            
    name'currency_name'
            
    type'string'
        
    }
        ],
        
    proxy: {
            
    type'ajax',
            
    url '/route.php?params=currency',
            
    actionMethods'POST',
            
    reader: {
                
    type'json',
                
    root: function(data) {
                    if (
    data.error) {
                        return [];
                    } else {
                        return 
    data;
                    }
                }
            }
        }    
    });



    Ext.define('SIMOBILE.store.Currency', {
        
    extend'Ext.data.Store',
        
    model'SIMOBILE.model.Currency',
        
    requires: ['SIMOBILE.model.Currency'],   
        
    autoLoadtrue   
    }); 

    4) then I need to provide data relevant to the form - and I can only do this when all selectfield store will be downloaded.

    in extjs3 this problem was not
    Please help in solving this problem ...

  7. #6
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    What I would do is load the store of the dynamic selectfield, then when it is loaded, set the value of the field with the new correct value you got from the Ajax request.

    Code:
    //load data
    var data = {fieldValue: 1};
    //create a field
    field = Ext.create('Ext.field.Select', ...);
    //load the store with a callback
    field.getStore().load(function() {
        field.setValue(data.fieldValue);
    });
    Sorry if I am not understanding you..
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  8. #7
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default


    perhaps the solution will keep getting all incontroller store (stores [...])
    and retrieve data by Ext.StoreMgr.get ('Currency').
    - I checked and it works as I wanted ---

    But do not change the fact that the problem occurs in the case of dependent story - the passed ID

  9. #8
    Sencha - Sencha Touch Dev Team rdougan's Avatar
    Join Date
    Oct 2008
    Posts
    1,158
    Answers
    93
    Vote Rating
    6
    rdougan will become famous soon enough

      0  

    Default


    Sorry, still not understanding much.

    You mean that setting the value of the Select field is not working? If so, I have fixed a bunch of issues with Select field for the next release. Which will be released in the next few days.
    Sencha Inc.
    Robert Dougan - @rdougan
    Sencha Touch 2 and Ext JS 4 Core Team Member, SASS/Theming Wizard.

  10. #9
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default


    Your solution may be effective ... ;-) check of
    ;-)

    Quote Originally Posted by rdougan View Post
    What I would do is load the store of the dynamic selectfield, then when it is loaded, set the value of the field with the new correct value you got from the Ajax request.

    Code:
    //load data
    var data = {fieldValue: 1};
    //create a field
    field = Ext.create('Ext.field.Select', ...);
    //load the store with a callback
    field.getStore().load(function() {
        field.setValue(data.fieldValue);
    });
    Sorry if I am not understanding you..

  11. #10
    Sencha User demon222's Avatar
    Join Date
    Jan 2008
    Location
    Poland, Warsaw
    Posts
    134
    Answers
    4
    Vote Rating
    4
    demon222 is on a distinguished road

      0  

    Default


    Rdougan - thank you for your help ;-)

    You can even refine: datepickerfield
    and add the option "dateformat" - as for me, it is essential

Thread Participants: 2