Results 1 to 2 of 2

Thread: Dynamic grids

  1. #1
    Sencha User
    Join Date
    Apr 2012
    Posts
    1

    Default Dynamic grids

    Hello. I would like to prepare the grid component in our project. I want to use this grid with respect to used store and connected model. It means columns of the grid should be constructed according to model fields.

    Code:
    Ext.application( {
        name: 'UserManagement',
        launch: function() {  
            Ext.create( 'Ext.container.Viewport', {
                layout: 'fit',
                items: [
                    Ext.create( 'My.grid', {
                        store: this.getController( 'My.Apps.user.controllers.Users' ).getStore('My.Apps.user.stores.Users' )
                    } )
                ]
            } );
        },
    
        controllers: [ 'My.Apps.user.controllers.Users' ]
    } );
    Store:
    Code:
    Ext.define( 'My.Apps.user.stores.Users', {
        extend: 'Ext.data.Store',
        model: 'My.Apps.user.models.User',
        autoLoad: true
    } );
    Model:
    Code:
    Ext.define( 'My.Apps.user.models.User', {
        extend: 'Ext.data.Model',
        fields: [
                    {
                        useNull: true,
                        name: 'id',
                        type: 'integer',
                        required: true,
                        label: 'Id'
                    },
                    {
                        name: 'firstName',
                        type: 'short-string',
                        required: true,
                        label: 'First Name'
                    }
            ]
    } );
    In the grid we need to find what fields are defined in the model. We have this.store.

    Code:
    var entityItems = this.store.model.fields.items;// Doesn't work
    How to find what fields are used in the model? I am able to do this.store.model.prototype.fields.items; but it doesn't seems to be right way. Is it suitable to solve this kind of problem by prototype? Thank you.

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

    Default

    See if this post helps:
    http://www.sencha.com/forum/showthread.php?196701

    Regards,
    Scott.

Posting Permissions

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