Results 1 to 2 of 2

Thread: How to populate an Ext.Grid declared in a js file to another js file

  1. #1
    Sencha User
    Join Date
    Jun 2010
    Posts
    56

    Question How to populate an Ext.Grid declared in a js file to another js file

    Hi All,

    I am facing a problem in extending Ext.Grid component.

    I have two js files sample1.js and main.js
    I want to populate the Grid declared in sample1.js file to the Ext.Window in main.js file.

    I want to break down the components in separate js files and then integrate in main.js file
    Can any one help me on this.

    Code for sample1.js file
    Code:
    MyGrid = Ext.extend(Ext.grid.GridPanel, {
        initComponent:function() {
            var config = {
                 store:new Ext.data.Store({
         			proxy: new Ext.data.HttpProxy(
         					new Ext.data.Connection({
         						url:'getalarm.htm'
         					})
    
         				),
         				reader:new Ext.data.JsonReader({
         					totalProperty:'total',
         					root:'rows',
         					fields: [
         					          'alarmsId',
         					          'severity',
         					          'condType',
         					          'remarks'
         					        ]
         				})
         			})
                ,columns: [
                           {header: "alarmsId", width: 170, sortable: true, dataIndex: 'alarmsId'},
                           {header: "severity", width: 170, sortable: true, dataIndex: 'severity'},
                           {header: "condType", width: 170, sortable: true, dataIndex: 'condType'},                      
                           {header: "remarks", width: 170, sortable: true, dataIndex: 'remarks'},
                       ]
                
            }; 
     
          
            Ext.apply(this, Ext.apply(this.initialConfig, config));
     
            
            
            MyGrid.superclass.initComponent.apply(this, arguments);
        } 
     
        ,onRender:function() {
     
            // call parent
        	MyGrid.superclass.onRender.apply(this, arguments);
     
            // load the store
            this.store.load();
     
        } // eo function onRender
     
    });
    Ext.reg('myGrid', MyGrid);

    Main.js file code
    Code:
    Ext.onReady(function(){
    
    	 
    
        var tabActions = new Ext.Panel({
        	frame:true,
        	title: 'Actions',
        	collapsible:true,
        	items:[{
                xtype:'myGrid'
               ,id:'grid'
               ,title:'Grid'
               ,region:'center'
               ,layout:'fit'
               
           }]
        });
        
        var win1 = new Ext.Window({
            layout:'fit',
            width:900,
            height:450,
            closable: false,
            resizable: true,
            plain: true,
            border: true,
            items: [tabActions]
    	});
    	win1.show();
        
    });
    How can i populate myGrid in main .js file.

    Expecting valuable comments from all.
    Thanks in advance

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    What do you mean by 'populate'?

    ps. Going by it's name, shouldn't tabActions be a TabPanel? If it isn't, then why do you even need tabActions? You could be using the grid directly!

Similar Threads

  1. Saki - File upload - Doesn't give an absolute path of a file in FF
    By amodg in forum Ext 3.x: Help & Discussion
    Replies: 12
    Last Post: 4 Apr 2010, 9:02 PM
  2. populate data from property file to combo box
    By sajjan in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 26 Mar 2009, 3:51 AM
  3. How to Populate <p> tag from a XML file into a xml-grid?
    By lazyleo in forum Ext 2.x: Help & Discussion
    Replies: 9
    Last Post: 17 Feb 2009, 5:31 AM
  4. file upload file in an ext.window
    By anitsirc in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 10 Sep 2008, 1:12 PM
  5. Replies: 2
    Last Post: 4 Mar 2008, 6:54 AM

Posting Permissions

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