1. #21
    Ext User
    Join Date
    Dec 2008
    Posts
    2
    Vote Rating
    0
    jayantkolekar is on a distinguished road

      0  

    Default


    Thank you very much for your help.

  2. #22
    Ext User
    Join Date
    Apr 2008
    Posts
    23
    Vote Rating
    -1
    Judy is an unknown quantity at this point

      0  

    Default A question...

    A question...


    [FONT='Verdana','sans-serif']I like the dynamic grid function. It basically works. But, if I am rendering it into a window container, there is an issue with scope chain. Basically, if I deem the store which generates the grid in the scope that above the window (like if I use a button to put window renderer on button click event), it works - because the grid was already fulfilled and just waiting to be rendered into a container. But, if I put window in the higher scope chain it would not. [/FONT]

    [FONT='Verdana','sans-serif']I understand why this is happening (although I may have failed to articulate it clearly). I am just wondering if anyone has a suggestion on how to have the grid refer to store's property instead of having it encapsulated within the store event. I could not figure it out.[/FONT]

  3. #23
    Ext User
    Join Date
    Oct 2008
    Posts
    8
    Vote Rating
    0
    sambar is on a distinguished road

      0  

    Default


    I get a H is null error, any suggestions ?

  4. #24
    Ext User
    Join Date
    Apr 2008
    Posts
    8
    Vote Rating
    0
    kishorebondada is on a distinguished road

      0  

    Default DynamicXMLReader

    DynamicXMLReader


    Hello spextjs,

    Did you manage to develop a DynamicXMLReader too ? Would be very useful for my problem.

    Atleast, any pointers/suggestions you would offer, if i were building one ?

  5. #25
    Ext User stedav's Avatar
    Join Date
    May 2009
    Location
    Turku, Finland
    Posts
    13
    Vote Rating
    3
    stedav is on a distinguished road

      0  

    Default Thanks, this is really appreciated

    Thanks, this is really appreciated


    Thanks for this, but I'm getting an annoying error when I am using:

    Code:
    new Ext.grid.DynamicColumnModel(ds)'
    ..as the column model attribute for my grid. However, Firebug is telling me off its showing the following script error:

    Ext.grid.DynamicColumnModel is not a constructor
    I've followed your code almost to the letter (swapping out variable names obviously), but to no avail. The Constructor to my grid looks like this: (# beign a place holder for my actual names which are company based hence I wish not show them).

    Code:
    
    var #name = new Ext.grid.EditorGridPanel
        (
            {
                    id:'#id',
                    store:#ds,
                    plain: true,
                    colModel:new Ext.grid.DynamicColumnModel(#ds), //firebug error here
                    autoScroll:true,
                    stripeRows :true,
                    autoExpandColumn:'#colname',
                    width: '70%'
            }
    
        );
    
    


    ]I'm probably missing something plainly obvious here, but any suggestions?

    If it can't be found, then don't look !

  6. #26
    Ext User
    Join Date
    Mar 2010
    Posts
    79
    Vote Rating
    0
    jtpacheco is on a distinguished road

      0  

    Default Missing methods :(

    Missing methods :(


    The problem is that Ext.grid.DynamicColumnModel(obj) no longer exists in Ext 3.x, so you'll never be able to use that function. Currently I have no idea how to get grid columns loaded on the fly. My page is used for running queries to a Solr db, and displays the results in a grid. Current, it works for a set of data that I know to be there, and therefore is correct for only that query term. However, if I query other things, it obviously doesn't show up.

    I'm not sure how to go about getting this done, as a lot of the forum suggestions are outdated (like this). The most I've thought of is to pass the column data with the JSON returned from query, but even then I don't know how to load that up to the column fields. I'm still tinkering with it, and eventually I'll find something, I'm sure...

    Quote Originally Posted by stedav View Post
    Thanks for this, but I'm getting an annoying error when I am using:

    Code:
    new Ext.grid.DynamicColumnModel(ds)'
    ..as the column model attribute for my grid. However, Firebug is telling me off its showing the following script error:

    I've followed your code almost to the letter (swapping out variable names obviously), but to no avail. The Constructor to my grid looks like this: (# beign a place holder for my actual names which are company based hence I wish not show them).

    Code:
    
    var #name = new Ext.grid.EditorGridPanel
        (
            {
                    id:'#id',
                    store:#ds,
                    plain: true,
                    colModel:new Ext.grid.DynamicColumnModel(#ds), //firebug error here
                    autoScroll:true,
                    stripeRows :true,
                    autoExpandColumn:'#colname',
                    width: '70%'
            }
    
        );
    
    


    ]I'm probably missing something plainly obvious here, but any suggestions?


  7. #27
    Ext User
    Join Date
    May 2010
    Posts
    3
    Vote Rating
    0
    djoo is on a distinguished road

      0  

    Default


    ExtJs forum volunteer. No official connection to the Ext Company. I do not speak for them.
    ExtJs consultancy offered. £ 50/hour. Evenings+weekends. animal.software@btinternet.com

    Search the forum: http://www.google.com/coop/cse?cx=01...%3Az7of1ufqccu
    Read the docs too: http://extjs.com/deploy/dev/docs/
    See Saki's samples: http://examples.extjs.eu/
    Build your own Ext: http://extjs.com/products/extjs/build/
    Scope: http://extjs.com/forum/showthread.ph...642#post257642
    منتديات فلاي عرب 3
    http://www.flyarb3.com

  8. #28
    Ext User
    Join Date
    Jun 2010
    Posts
    1
    Vote Rating
    0
    kalyan1230 is on a distinguished road

      0  

    Default


    I need small help in the below mentioned code.

    for (var i = 0; i < fields.keys.length; i++)
    {
    var fieldName = fields.keys[i];
    var field = recordType.getField(fieldName);
    cols[i] = {header: field.name, dataIndex: field.name, width:300};
    }

    I need Sorting on the column so i have added sortable:true, but the sorting is not working.

    Can u please help me out for Sorting in DynamicColumnModel


    Quote Originally Posted by SteveEisner View Post
    Here's what I came up with:

    Dynamic Json Reader: this will read whatever data comes back from the JSON call. It doesn't take a record definition because it builds it on the fly. Unfortunately it only has any record information *after* the JSON call has completed, so you can't simply pass it into a Grid, etc. because it won't be initialized at that time.

    Code:
    Ext.data.DynamicJsonReader = function(config){
        Ext.data.DynamicJsonReader.superclass.constructor.call(this, config, []);
    };
    Ext.extend(Ext.data.DynamicJsonReader, Ext.data.JsonReader, {
        getRecordType : function(data) {
            var i = 0, arr = [];
            for (var name in data[0]) { arr[i++] = name; } // is there a built-in to do this?
            
            this.recordType = Ext.data.Record.create(arr);
            return this.recordType;
            },
            
        readRecords : function(o){ // this is just the same as base class, with call to getRecordType injected
            this.jsonData = o;
            var s = this.meta;
            var sid = s.id;
            
            var totalRecords = 0;
            if(s.totalProperty){
                var v = parseInt(eval("o." + s.totalProperty), 10);
                if(!isNaN(v)){
                    totalRecords = v;
                }
            }
            var root = s.root ? eval("o." + s.root) : o;
            
            var recordType = this.getRecordType(root);
            var fields = recordType.prototype.fields;
            
            var records = [];
            for(var i = 0; i < root.length; i++){
                var n = root[i];
                var values = {};
                var id = (n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
                for(var j = 0, jlen = fields.length; j < jlen; j++){
                    var f = fields.items[j];
                    var map = f.mapping || f.name;
                    var v = n[map] !== undefined ? n[map] : f.defaultValue;
                    v = f.convert(v);
                    values[f.name] = v;
                }
                var record = new recordType(values, id);
                record.json = n;
                records[records.length] = record;
            }
            return {
                records : records,
                totalRecords : totalRecords || records.length
            };
        }
    });
    DynamicColumnModel: this takes a Store as a parameter, and from that it will build a default ColumnModel where all the fields are included and have width: 300.

    Code:
    Ext.grid.DynamicColumnModel = function(store){
        var cols = [];
        var recordType = store.recordType;
        var fields = recordType.prototype.fields;
        
        for (var i = 0; i < fields.keys.length; i++)
        {
            var fieldName = fields.keys[i];
            var field = recordType.getField(fieldName);
            cols[i] = {header: field.name, dataIndex: field.name, width:300};
        }
        Ext.grid.DynamicColumnModel.superclass.constructor.call(this, cols);
    };
    Ext.extend(Ext.grid.DynamicColumnModel, Ext.grid.ColumnModel, {});
    Here's how I use it -

    Code:
    function showGrid(container, url)
    {
        // create the Data Store
        var ds = new Ext.data.Store({
            proxy: new Ext.data.HttpProxy({url: url}),
            reader: new Ext.data.DynamicJsonReader({root: '...my root, yours will be different...'}),
            remoteSort: true
            });
        ds.on('load', function() {
            // Reset the Store's recordType
            ds.recordType = ds.reader.recordType;
            ds.fields = ds.recordType.prototype.fields;
    
            // Create the grid
            var grid = new Ext.grid.Grid(container, {
               ds: ds,
               cm: new Ext.grid.DynamicColumnModel(ds),
               selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
               enableColLock:true
            });
               
            // render it
            grid.render();
        });
        ds.load();
    }
    I haven't really put it through its paces yet but it seems to work for whatever JSON calls I try. If this were more generic I'd want to add some things like:
    * Some way to provide column widths and types for known columns - merge with the unknowns. Maybe a callback function of some sort.
    * A better way to declare this type of grid that has to wait until the data has been fetched before rendering.
    * A DynamicXmlReader to match the JSON reader
    * etc.

    Note if Jack reads this: the DynamicJsonReader code could be even smaller if you adopt the change I made to the readRecords() method...

    Steve

  9. #29
    Sencha User
    Join Date
    Apr 2010
    Posts
    25
    Vote Rating
    0
    k0smita is on a distinguished road

      0  

    Default


    To get DynamicJsonReader working I had to add two more lines to getRecordType (to call buildExtractors). Now the current version looks like that:
    PHP Code:
    Ext.ns('Ext.data.DynamicJsonReader');

    Ext.data.DynamicJsonReader = function(config)
    {
        
    Ext.data.DynamicJsonReader.superclass.constructor.call(thisconfig, []);
    };

    Ext.extend(Ext.data.DynamicJsonReaderExt.data.JsonReader, {
        
    /**
         * Create Record automatically based on json data
         * Private, called by readRecords()
         * @param {Object} data Json data
         */
        
    getRecordType: function(data) {
            var 
    0arr = [];

            for (var 
    name in data[0]) { arr[i++] = name; } // is there a built-in to do this?

            
    this.recordType Ext.data.Record.create(arr);
            
            
    this.ef false;
            
    this.buildExtractors();
            
            return 
    this.recordType;
        },
        
        
    /**
         * Create a data block containing Ext.data.Records from a JSON object.
         * @param {Object} o An object which contains an Array of row objects in the property specified
         * in the config as 'root, and optionally a property, specified in the config as 'totalProperty'
         * which contains the total size of the dataset.
         * @return {Object} data A data block which is used by an Ext.data.Store object as
         * a cache of Ext.data.Records.
         */
        
    readRecords : function(o){
            
    /**
             * After any data loads, the raw JSON data is available for further custom processing.  If no data is
             * loaded or there is a load exception this property will be undefined.
             * @type Object
             */
            
    this.jsonData o;
            if(
    o.metaData){
                
    this.onMetaChange(o.metaData);
            }
            
    //start modifications
            
    var root this.getRoot(o), root.lengthtotalRecords csuccess true;
            
            var 
    this.metaRecord this.getRecordType(root),
                
    Record.prototype.fieldsfi f.itemsfl f.lengthv;
            
    //end modifications
            
            
    if(s.totalProperty){
                
    parseInt(this.getTotal(o), 10);
                if(!
    isNaN(v)){
                    
    totalRecords v;
                }
            }
            if(
    s.successProperty){
                
    this.getSuccess(o);
                if(
    === false || === 'false'){
                    
    success false;
                }
            }

            
    // TODO return Ext.data.Response instance instead.  @see #readResponse
            
    return {
                
    success success,
                
    records this.extractData(roottrue), // <-- true to return [Ext.data.Record]
                
    totalRecords totalRecords
            
    };
        }
    }); 

  10. #30
    Ext User
    Join Date
    Dec 2009
    Posts
    23
    Vote Rating
    0
    asbestos girl is on a distinguished road

      0  

    Default


    Another way to achieve dynamic column grids is using metaData.

    in your js:
    Code:
    var ds = new Ext.data.Store({
                    url: '/cgi-bin/get_dynamic_grid_data.pl', // your script that fetches the data
                    reader: new Ext.data.JsonReader({
                            root: 'rows',
                            successProperty: 'success'
                    })
            });
    
            var grid = new Ext.grid.GridPanel({
                    ds: ds,
                    cm: new Ext.grid.ColumnModel([])
            });
            grid.render(Ext.getBody())
    
            ds.on('metachange', function (store,meta) {
                    var columns = [];
            
                    for (var i = 0; i < meta.fields.length; i++ ) {
                            var hidden = meta.fields[i].hidden;
                            columns.push( { header: meta.fields[i].header, dataIndex: meta.fields[i].name, type: meta.fields[i].type, id: meta.fields[i].id, sortable: meta.fields[i].sortable } );
                    }
    
                    grid.reconfigure(store, new Ext.grid.ColumnModel(columns));
            })
    Then in your data fetching script return json in this format (called /cgi-bin/get_dynamic_grid_data.pl in this example):
    Code:
    {
            metaData: {
                    fields: [
                            {header: 'Name', name: 'name', sortable: true},
                            {header: 'URL', name: 'url'},
                            {header: 'Size', name: 'size'},
                            {header: 'Last Modified', name: 'lastmod'}
                    ],
                    root: 'rows'
            },
            rows: [
                    {name: 'Image one', url:'/GetImage.php?id=1', size:46.5, lastmod: new Date(2007, 10, 29)},
                    {name: 'Image Two', url:'/GetImage.php?id=2', size:43.2, lastmod: new Date(2007, 10, 30)}
            ],
            success: true
    }
    The advantage of doing it this way is less code (no extensions required) and you can change the column model on one rendered grid as many times as you want. It also resolved the problem of being able to provide column widths, data types, sortable etc.

Similar Threads

  1. Max columns limitation in grid?
    By jarrod in forum Ext 1.x: Bugs
    Replies: 9
    Last Post: 26 Jun 2010, 4:52 AM
  2. Dynamic Columns for Grid
    By kinky_lizzard in forum Ext 1.x: Help & Discussion
    Replies: 7
    Last Post: 24 May 2010, 11:20 PM
  3. Grid - Double Header Columns
    By FuryVII in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 23 Feb 2007, 7:21 AM
  4. Nested Grid Columns
    By dlibby00 in forum Community Discussion
    Replies: 4
    Last Post: 29 Jan 2007, 9:53 AM

Thread Participants: 30

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar