Results 1 to 2 of 2

Thread: Values From Store To TextBoxes

  1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    31
    Vote Rating
    0
      0  

    Exclamation Answered: Values From Store To TextBoxes

    hello everyone !
    i want to show my records from store to textboxes , i have three textboxes
    1-userid
    2-username
    3-userdepartment
    now i have a button , search . i have done to get the values of the userid entered by the user and my webservice is send all records in a very good way to my store , now i want that when ever i press search , my store will show values to my textboxes , here is my code .
    Code:
                var myForm = new Ext.FormPanel({
                        id: 'city-form',
                        renderTo: bd,
                        frame: true,
                        labelAlign: 'left',
                        title: 'Invoice',
                        bodyStyle: 'padding:5px',
                        width: 670,
                        items: [{
                            xtype: 'textfield', name: 'UserID', id: 'UserID', fieldLabel: 'UserID'
                        }, { xtype: 'textfield', name: 'Username', id: 'Username', fieldLabel: 'UserName' 
                        }, { xtype: 'textfield', name: 'UserDepartment', id: 'UserDepartment', fieldLabel: 'UserDepartment' 
                        }, {xtype:'button',text:'search',
                            handler:function(){
                               
                              }
                            }         
                  }]
    
    
                    });
    now here is my store
    Code:
                var storeHead = new Ext.data.Store({
                    autoLoad: true,
                    autoDestroy: true,
                    reader: new Ext.data.ArrayReader(
                        { root: 'd',
                            id: 'UserID',
                            fields: ['UserID','UserName','UserDepartment']
                        })
    
    
                    , proxy: new Ext.data.HttpProxy({
                        url: 'services/myWebService.asmx/GetUsers?id=100', // ASP.NET WebService call in GET format
    
    
                        headers: {
                            'Content-type': 'application/json' // IMPORTANT! Without this FireFox will not understand WebService response 
                        }
                    })
                });
    now here is my records
    Code:
          var myUsersRec = new Ext.data.Record.create(
                     [
                           { name: 'UserID' },
                           { name: 'Username' },
                           { name: 'UserDepartment' }
                     
                     ]
        );
    please guide me how can i perform my required task .

    Best Regards

  2. assuming that after filtering there is only one record in the store, you can do something like this in "Search" button handler :

    Code:
    storeHead.load({
        params : {
            userId : id, //id from textfield
        },
        callback : function(records, operation, success) {
            if (success) {
                myForm.getForm().loadRecord(records[0]);
            }
        }
    });

  3. #2
    chramer's Avatar
    Join Date
    Feb 2011
    Location
    Chisinau, Moldova
    Posts
    316
    Answers
    64
    Vote Rating
    33
      0  

    Default

    assuming that after filtering there is only one record in the store, you can do something like this in "Search" button handler :

    Code:
    storeHead.load({
        params : {
            userId : id, //id from textfield
        },
        callback : function(records, operation, success) {
            if (success) {
                myForm.getForm().loadRecord(records[0]);
            }
        }
    });

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •