1. #1
    Sencha User
    Join Date
    Nov 2012
    Posts
    1
    Vote Rating
    0
    sani is on a distinguished road

      0  

    Default Unanswered: Dynamic Grid WIth Direct

    Unanswered: Dynamic Grid WIth Direct


    I share my here :

    Code:
    Ext.require([
        'Ext.direct.*',
        'Ext.data.*',
        'Ext.grid.*',
        'Ext.util.Format'
    ]);
    
    
    Ext.onReady(function() {
        Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
        
        //added model inside onready
        Ext.define('QueryReport', {
            extend: 'Ext.data.Model',
            fields: ['ID_FAKULTAS', 'SINGKATAN_FAKULTAS', 'NM_FAKULTAS', 'ALAMAT_FAKULTAS']
        });
        
        //separated store into unique var for guaranteeRange
        var store = Ext.create('Ext.data.Store', {
            model: 'QueryReport',
            autoLoad: true,
            proxy: {
                type: 'direct',
                directFn: QueryDatabase.getResults,
            }
        });
        
        //create the grid
        var grid = Ext.create('Ext.grid.Panel', {
            height: 450,
            width: 700,
            title: 'Velociraptor Owners',
            store: store,
            columns: [{
                dataIndex: 'ID_FAKULTAS',
                width: 50,
                text: 'ID'
            }, {
                dataIndex: 'SINGKATAN_FAKULTAS',
                flex: 1,
                text: 'Singkatan'
            }, {
                dataIndex: 'NM_FAKULTAS',
                flex: 1.3,
                text: 'Nama'
            }, {
                dataIndex: 'ALAMAT_FAKULTAS',
                flex: 1,
                text: 'Alamat'
            }],
            renderTo: Ext.getBody()
        });
    });
    I have problem here, how to make my code
    Code:
    fields: ['ID_FAKULTAS', 'SINGKATAN_FAKULTAS', 'NM_FAKULTAS', 'ALAMAT_FAKULTAS']
    get dynamic from store json data
    so this code
    Code:
            columns: [{            dataIndex: 'ID_FAKULTAS',
                width: 50,
                text: 'ID'
            }, {
                dataIndex: 'SINGKATAN_FAKULTAS',
                flex: 1,
                text: 'Singkatan'
            }, {
                dataIndex: 'NM_FAKULTAS',
                flex: 1.3,
                text: 'Nama'
            }, {
                dataIndex: 'ALAMAT_FAKULTAS',
                flex: 1,
                text: 'Alamat'
            }],
    dynamic also.

    I mean, i want to make dynamic gridpanel generated dynamic by "QueryDatabase".

    sani

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,714
    Vote Rating
    438
    Answers
    3113
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    The store needs to have a model defined. Do note that specifying the fields config creates a new model definition and uses that.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!

    When posting code, please use BBCode's CODE tags.