Hybrid View

  1. #1
    Sencha User
    Join Date
    Jul 2013
    Posts
    4
    Vote Rating
    0
    fahadaziz is on a distinguished road

      0  

    Default Unanswered: how to get selected row values from data grid view in form's textbox extjs

    Unanswered: how to get selected row values from data grid view in form's textbox extjs


    Hi all,

    I am a newbie of extjs and do not know too much about extjs. I want to get values from data grid view in to the form textbox.

    here is my code of app.js

    Code:
    Ext.require([
        'Ext.data.*',
        'Ext.form.*',
        'Ext.grid.*',
    	'Ext.grid.Panel',
    	
    ]);
    
    
    
    
    
    
    
    
    
    
    Ext.onReady(function(){
    
    
        Ext.define('Person',{
            extend: 'Ext.data.Model',
            fields: [
                'salutation', 'title', 'firstName'
            ],
    		
    		
        });
        
    	
        
    
    
        // create the Data Store
        var store = Ext.create('Ext.data.Store', {
            model: 'Person',
            autoLoad: true,
            proxy: {
                type: 'memory',
                    data: getFormData(),
                    reader: {
                        type: 'array'
                    }
            }
        });
    
    
        // create the grid
        var billingGrid = Ext.create('Ext.grid.Panel', {
            store: store,
            columns: [
                {text: "salutation", width:120, dataIndex: 'salutation'},
                {text: "title", width: 120, dataIndex: 'title'},
    			{text: "firstName", width: 120, dataIndex: 'firstName'}
            ],
            renderTo:'example-grid',
            width: 350,
            height: 180
        });
        
        
        
        var addUserForm = Ext.create('Ext.form.Panel', {
            renderTo: Ext.getBody(),
            bodyStyle: 'padding: 5px 5px 0 5px;',
            defaults: {
                xtype: 'textfield',
                anchor: '100%',
             },
            items: [{
                fieldLabel: 'salutation',
                name: 'salutation',
                maxLength: 64,            
                allowBlank: false,
                
                
            },{
                fieldLabel: 'Title',
                name: 'title',
                
                maxLength: 64,            
                allowBlank: false,
                
            },{
                fieldLabel: 'First Name',
                name: 'firstName',
                
                maxLength: 64,            
                allowBlank: true,
                
            }
            ,{
                fieldLabel: 'Address',
                name: 'address',
                
                maxLength: 64,            
                allowBlank: true,
                
            }],
            buttons: [{
                id: 'saveBtn',
                itemId: 'saveBtn',
                text: 'Submit',
                handler: function(btn, event) {
                   // this.up('form').getForm().submit();
                	 
    				var values= addUserForm.getValues();
    				Ext.Msg.alert('Welcome', Ext.String.format('{0},{1},{2}',values.salutation,values.title,values.firstName));
    				
                     // Create a record instance through the ModelManager
                     var r = Ext.ModelManager.create({
                    	 salutation: values.salutation,
                         title: values.title,
                         firstName: values.firstName,
                         active: true
                     }, 'Person');
    
    
                     store.insert(0, r);
                     
                }
            },{
                text: 'Cancel',
                handler: function() {
                    this.up('form').getForm().reset();
                }
            }],
            submit: function() {
            
                
                
            }
        }); //end of form creation
        
        
        
        function getFormData(){
    	
    							arrayData=[['Professor', 'Dr', 'Ghulam Murtaza']];
    							return arrayData;
    							}
    							
    							/* this.billingGrid.getSelectionModel().on('rowselect',function(sm,rowIdx,r){
    							
    							var selectedRecord = this.billingGrid.getSelectionModel().getSelected();
    							if (selectedRecord !=null){
    							
    							var firstName= selectedRecord.get('firstName');
    							
    							}
    							alert (firstName);
    							}
    							); */
    							
    							this.billingGrid.getSelectionModel().on('rowselect',function(sm, rowIdx, r){
        				var selectedRecord = this.billingGrid.getSelectionModel().getSelected();
        				if (selectedRecord != null){
        					 var firstName = selectedRecord.get('firstName');
    						 alert(firstName);
        				}});
    						
    		});
    thanks,
    fadi.

  2. #2
    Sencha User
    Join Date
    Apr 2013
    Posts
    7
    Vote Rating
    0
    Alex_Dutch is on a distinguished road

      0  

    Default


    You need some event action that call form and than fill from.
    In my project I use MVC and in controller I have event listener:

    PHP Code:
    Ext.define('MyApp.controller.Users', {
         
    extend'Ext.app.Controller',

         
    init: function() {
             
    this.control({

                
    'gridpanel': {
                    
    itemdblclickthis.editRow//on event dblclick call function editRow
                
    },
                ... 
    // others obj and events
           
    })
    },
        
    editRow: function(gridrecord) {
            var 
    view Ext.widget('rowEdit');     // set some alias in form panel (alias : 'widget.rowEdit') thereat you can call then
            
    view.down('form').loadRecord(record); // and fill form
        
    }
    }); 
    On this example you can copy function to listener in gridPanel. But don't forget set alias to form.

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi