1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    90
    Answers
    2
    Vote Rating
    2
    darkhorni is on a distinguished road

      0  

    Default Unanswered: Creating a Dynamic Grid with ExtJS

    Unanswered: Creating a Dynamic Grid with ExtJS


    I'm trying to make a Dynamic Grid class (where I do not know any information about the columns but they are given from the json response and the gird prepares itself accordingly). Here I have found exactly what I was looking for however it gives me an error:

    Code:
    me.model is undefined
    me.setProxy(me.proxy || me.model.getProxy());
    ext-all-debug.js (line 47323)
    I have tried to add both proxy and model but I was not successful, I kept getting the same error.
    Here is the ExtJS code that I'm working on:


    PHP Code:
    // ExtJS 4.1
    Ext.Loader.setConfig({enabledtrue});
    Ext.Loader.setPath('Ext.ux''../extjs-4.1.0/examples/ux');
    Ext.require([
        
    'Ext.grid.*',
        
    'Ext.data.*',
    ]);


    Ext.define('DynamicGrid', {
    extend'Ext.grid.GridPanel',
        
    storeUrl'',
        
    enableColumnHide:true,
        
    initComponent: function(){
            var 
    store = new Ext.data.Store({
                
    urlthis.storeUrl,
                
    reader: new Ext.data.JsonReader(),
                
    autoLoadtrue,
                
    scopethis,
                
    listeners: {
                    
    scopethis,
                    
    metachange: function(storemeta) {
                        if(
    typeof(store.reader.jsonData.columns) === 'object') {
                            var 
    columns = [];
                            
    /**
                            * Adding RowNumberer or setting selection model as CheckboxSelectionModel
                            * We need to add them before other columns to display first
                            */
                            
    if(this.rowNumberer) {
                                
    columns.push(new Ext.grid.RowNumberer());
                            }
                            if(
    this.checkboxSelModel) {
                                
    columns.push(new Ext.grid.CheckboxSelectionModel());
                            }
                            
    Ext.each(store.reader.jsonData.columns, function(column){
                                
    columns.push(column);
                            }); 
    // Set column model configuration 
                            
    this.getColumnModel().setConfig(columns); 
                            
    this.reconfigure(storethis.getColumnModel());
                        }
                    }
                }
            });
            var 
    config = {
                
    title'Dynamic Columns',
                
    viewConfig:{
                    
    emptyText:'No rows to display'
                
    },
                
    loadMasktrue,
                
    borderfalse,
                
    stripeRowstrue,
                
    storestore,
                
    columns: []
            }
            
    Ext.apply(thisconfig);
            
    Ext.apply(this.initialConfigconfig);
            
    DynamicGrid.superclass.initComponent.apply(thisarguments);
        },
        
    onRender: function(ctposition){
            
    this.colModel.defaultSortable true;
            
    DynamicGrid.superclass.onRender.call(thisctposition);
        }
    });

    Ext.onReady(function(){


        
    Ext.QuickTips.init();

        var 
    grid Ext.create('DynamicGrid', {
    storeUrl'http://300.79.103.188/ApplicationJs/jsontest.json'
        
    });

        var  
    depV Ext.create('Ext.Viewport', {
            
    title'Departman Tanımları',
            
    layout'fit',
            
    itemsgrid
        
    }).show();

    }); 
    What I have to do inorder to make it run?

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,990
    Answers
    663
    Vote Rating
    455
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Have a look at the following thread?
    http://www.sencha.com/forum/showthread.php?223802

    Scott.

Thread Participants: 1

Tags for this Thread