Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: this.config[col] has no properties

  1. #1

    Question this.config[col] has no properties

    Can anyone tell me what might cause the following error:

    this.config[col] has no properties

    Attached is part of the code used:

    Code:
    	buildGrid : function(data){
    	
            var ds = new Ext.data.Store({
    		        proxy: new Ext.data.MemoryProxy(data),
    		        reader: new Ext.data.ArrayReader({}, [
                           {name: 'colA', type: 'int'},
                           {name: 'ColB', type: 'string'},
                           {name: 'ColC', type: 'int'}
                      ])
            });
            ds.load();
            
            var colModel = new Ext.grid.ColumnModel([
    			{id:'id',header: "id", width: 75, sortable: true, visible: false, dataIndex: 'aaa'},
    			{header: "ColA", width: 160, sortable: true, locked:false, dataIndex: 'bbb'},
    			{header: "colB", width: 75, sortable: true, dataIndex: 'ccc'}
    		]);
    		
            var grid = new Ext.grid.Grid('grid-example', {
                ds: ds,
                cm: colModel
            });
            
            var layout = Ext.BorderLayout.create({
                center: {
                    margins:{left:3,top:3,right:3,bottom:3},
                    panels: [new Ext.GridPanel(grid)]
                }
            }, 'grid-panel');
    
            grid.render();
            
            grid.getSelectionModel().selectFirstRow();
    	
    	}
    Last edited by Animal; 18 May 2007 at 9:59 PM. Reason: Added code tags

  2. #2
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    * I'm fairly sure that your dataIndex should point to a field in the reader, e.g.,

    Code:
    {header: "ColA", width: 160, sortable: true, locked:false, dataIndex: 'bbb'},
    should be re-written as

    Code:
    {header: "ColA", width: 160, sortable: true, locked:false, dataIndex: 'colA'},
    Note: I'm using your spelling, i.e., colA and not ColA.

    * Also fairly sure that you should call ds.load() after grid.render()

    Sorry that's all I've got...

    FYI, a lot of folk find it hard to read the code when it's not wrapped in CODE's - see the # in the editor.

  3. #3

    Smile Complete Code

    here is the complete JS code and below the Json string result which gets passed buildGrid

    buildGrid : function(data){

    var ds = new Ext.data.Store({
    proxy: new Ext.data.MemoryProxy(data),
    reader: new Ext.data.ArrayReader({root:'data',id:'id'}, [
    {name: 'available', type: 'int'},
    {name: 'name', type: 'string'},
    {name: 'id', type: 'int'}
    ])
    });

    var colModel = new Ext.grid.ColumnModel([
    {id:'id',header: "id", width: 75, sortable: true, visible: false, dataIndex: 'id'},
    {header: "Name", width: 160, sortable: true, locked:false, dataIndex: 'name'},
    {header: "View Available", width: 75, sortable: true, dataIndex: 'available'}
    ]);

    var grid = new Ext.grid.Grid('grid-example', {
    ds: ds
    ,cm: colModel
    ,loadMask: true
    ,selModel: new Ext.grid.RowSelectionModel({singleSelect:true})
    ,autoSizeColumns: true
    ,autoExpandColumn: 'Name'
    ,monitorWindowResize:true
    ,trackMouseOver: false
    });

    var layout = Ext.BorderLayout.create({
    center: {
    margins:{left:3,top:3,right:3,bottom:3},
    panels: [new Ext.GridPanel(grid)]
    }
    }, 'grid-panel');

    grid.render();

    // trigger the data store load
    ds.load();

    }

    JSON:
    { "data" : [ { "available" : "1" , "name" : "you.com" , "id" : "404" } , { "available" : "1" , "name" : "them.com" , "id" : "466" } , { "available" : "1" , "name" : "they.com" , "id" : "513" } , { "available" : "1" , "name" : "us.com" , "id" : "521" } ] }

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Don't you want to be using a JsonReader instead of ArrayReader?

  5. #5

    Default

    I did switch it to JsonReader, and I still get the error.

  6. #6

    Default Screenshot

    I've attached a screenshot of the errors.
    Attached Images Attached Images

  7. #7
    Sencha User fay's Avatar
    Join Date
    Apr 2007
    Location
    Ireland
    Posts
    1,750

    Default

    The problem seems to be that you are specifying 'Name' as the autoExpandColumn, but you have not included a Column id for this:

    Code:
    {id: 'Name', header: "Name", width: 160, sortable: true, locked:false, dataIndex: 'name'},
    To find this I opened the (working) array-grid example and modified it with your fields - one at a time - to get:

    Code:
    var Example = {
      init : function(){
    
        var data = [
          [1,'you.com',404],
          [1,'them.com',466]
        ];
    
        var ds = new Ext.data.Store({
          proxy: new Ext.data.MemoryProxy(data),
          reader: new Ext.data.ArrayReader({}, [
            {name: 'available', type: 'int'},
            {name: 'name', type: 'string'},
            {name: 'id', type: 'int'}
          ])
        });
    
        var colModel = new Ext.grid.ColumnModel([
          {id:'id',header: "Id", width: 75, sortable: true, dataIndex: 'id'},
    			{header: "Available", width: 160, sortable: true, locked:false, dataIndex: 'available'},      
    			{id: 'Name', header: "Name", width: 75, sortable: true, dataIndex: 'name'}			
    		]);
    
        var grid = new Ext.grid.Grid('grid-example', {
          ds: ds,
          cm: colModel,
          autoExpandColumn: 'Name'
        });
            
        var layout = Ext.BorderLayout.create({
          center: {
            margins:{left:3,top:3,right:3,bottom:3},
            panels: [new Ext.GridPanel(grid)]
            }
        }, 'grid-panel');
    
        grid.render();
        ds.load();
      }
    };
    Ext.onReady(Example.init, Example);
    Note, that I haven't included all your grid config options as 'tis teatime!

  8. #8
    Sencha User Animal's Avatar
    Join Date
    Mar 2007
    Location
    Bédoin/Nottingham
    Posts
    30,890

    Default

    The purpose of the Record definition parameter to the Reader constructor (param 2) is to provide for each data field, a mapping property that specifies the Json (or DomQuery if XmlReader is being used) path to the specified data item.

    The name property is what the field will be called when it is cached inside the Store object, and is what the dataIndex property of the ColumnModel refers to. By default, the name is set to the mapping if not specified.

  9. #9
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Please repost your current code in 'code' tags and the text of your errors (or a bigger image)

  10. #10

    Default

    I did take your code, made the changes and while it's not giving me the error anymore, it also doesn't display any data.

    <code>
    { "data" : [ { "available" : "1" , "name" : "you.com" , "id" : "404" } , { "available" : "1" , "name" : "them.com" , "id" : "466" } , { "available" : "1" , "name" : "us.com" , "id" : "513" } , { "available" : "1" , "name" : "they.com" , "id" : "521" } ] }
    </code>

Page 1 of 2 12 LastLast

Posting Permissions

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