Gelmiş geçmiş en büyük porno sitemiz olan 2pe de her zaman en kaliteli pornoları sunmayı hedefledik. Diğer video sitemiz olan vuam da ise hd porno ağırlıklı çalışmalara başladık.

  1. #1
    Sencha User
    Join Date
    Apr 2011
    Location
    Netherlands
    Posts
    51
    Vote Rating
    0
    TobyJustus is on a distinguished road

      0  

    Default Answered: Creating dynamic model/store

    Answered: Creating dynamic model/store


    I create a dynamic model with this code:

    Code:
     //dynamic model    modelFactory = function (name, fields) {
            console.log('Creating dynamic model and store');
    
    
            //create dynamic columns
            var modelFields = [];
    
    
            Ext.Array.each(fields, function (name, index, resultfields) {
    
    
                var this_modelField = {};
                this_modelField['mapping'] = name.name;
                this_modelField['name'] = name.name;
                modelFields.push(this_modelField);
            });
            //define names
            var modelName = name;
            var storeName = name;
    
    
            //create model
            Ext.define(modelName, {
                extend: 'Ext.data.Model',
                fields: modelFields
            });
            //create store
            ND.store = new Ext.data.Store({
    
    
    
    
                model: modelName,
                sortOnLoad: true,
                proxy: {
                    type: 'ajax',
                    url: '../json/result.json',
                    reader: {
                        type: 'json'
                    }
                },
                autoLoad: false
    
    
            });
    
    
            console.log('Dynamic model and store created');
        }
    This is working only the issue is that i always have the same store: ND.store. How can i create a dynamic store and use it in a grid?

  2. Quote Originally Posted by TobyJustus View Post
    Thanks,

    i use this in the function to create the grid:

    Code:
       
    modelFactory(rec.get('Reference'), rec.get('ResultFields'));
    var grid = Ext.create('Ext.grid.Panel', {
                             title: 'Gridview',
                            forceFit: true,
                            store: store,
                            columns: tabColumns
                        })
    But how will i know what the store name is? Now it will say store is not defined
    Code:
    var store = modelFactory(rec.get('Reference'), rec.get('ResultFields'));
    var grid = Ext.create('Ext.grid.Panel', {
    	title: 'Gridview',
    	forceFit: true,
    	store: store,
    	columns: tabColumns
    });

  3. #2
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Instead of assigning store to ND.store, you should assign it to a local variable and then return it to the calling.
    Code:
     //dynamic model    
     modelFactory = function (name, fields) {
        console.log('Creating dynamic model and store');
    
    
        //create dynamic columns
        var modelFields = [];
    
    
        Ext.Array.each(fields, function (name, index, resultfields) {
            var this_modelField = {};
            this_modelField['mapping'] = name.name;
            this_modelField['name'] = name.name;
            modelFields.push(this_modelField);
        });
        //define names
        var modelName = name;
        var storeName = name;
    
    
        //create model
        Ext.define(modelName, {
            extend: 'Ext.data.Model',
            fields: modelFields
        });
        //create store
        // ND.store = new Ext.data.Store({
        var store = Ext.create('Ext.data.Store', {
            model: modelName,
            sortOnLoad: true,
            proxy: {
                type: 'ajax',
                url: '../json/result.json',
                reader: {
                    type: 'json'
                }
            },
            autoLoad: false
        });
        console.log('Dynamic model and store created');
        return store;
    }

  4. #3
    Sencha User
    Join Date
    Apr 2011
    Location
    Netherlands
    Posts
    51
    Vote Rating
    0
    TobyJustus is on a distinguished road

      0  

    Default


    Thanks,

    i use this in the function to create the grid:

    Code:
       modelFactory(rec.get('Reference'), rec.get('ResultFields'));
    
    var grid = Ext.create('Ext.grid.Panel', {
    
                            title: 'Gridview',
                            forceFit: true,
                            store: store,
                            columns: tabColumns
                        })
    But how will i know what the store name is? Now it will say store is not defined

  5. #4
    Sencha User
    Join Date
    Apr 2011
    Location
    Netherlands
    Posts
    51
    Vote Rating
    0
    TobyJustus is on a distinguished road

      0  

    Default


    i have the store working:

    Code:
    var store = Ext.create('Ext.data.Store', {            model: modelName,
                id: storeID,
                sortOnLoad: true,
                proxy: {
                    type: 'ajax',
                    url: '../json/result.json',
                    reader: {
                        type: 'json'
                    }
                },
                autoLoad: false
    
    
            });
    return store;
    to load the function i do this:
    Code:
     var tabs = Ext.getCmp('northPanel');                    var rec = view.getStore().getAt(rowIndex);
                        var store = rec.get('Reference');
                        modelFactory(rec.get('Reference'), rec.get('ResultFields'), store);
    but now when i want to load or refresh a store i did this:

    Code:
     store.load({                                            
                                                url: '../json/result.json?'+form.getValues(true),
                                                                                    
                                            });
    but then i get the error store.load is not a function

    so i tried this:
    Code:
    rec.get('Reference').load({
    
                               url: '../json/result.json',
    
    
                            });
    now i get rec.get('Reference').load is not a function.

    How can i load a store?

  6. #5
    Sencha - Community Support Team
    Join Date
    Jan 2012
    Posts
    1,376
    Answers
    346
    Vote Rating
    113
    vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all vietits is a name known to all

      0  

    Default


    Quote Originally Posted by TobyJustus View Post
    Thanks,

    i use this in the function to create the grid:

    Code:
       
    modelFactory(rec.get('Reference'), rec.get('ResultFields'));
    var grid = Ext.create('Ext.grid.Panel', {
                             title: 'Gridview',
                            forceFit: true,
                            store: store,
                            columns: tabColumns
                        })
    But how will i know what the store name is? Now it will say store is not defined
    Code:
    var store = modelFactory(rec.get('Reference'), rec.get('ResultFields'));
    var grid = Ext.create('Ext.grid.Panel', {
    	title: 'Gridview',
    	forceFit: true,
    	store: store,
    	columns: tabColumns
    });

  7. #6
    Sencha User
    Join Date
    Apr 2011
    Location
    Netherlands
    Posts
    51
    Vote Rating
    0
    TobyJustus is on a distinguished road

      0  

    Thumbs up


    Thanks! This is doing the trick!

Thread Participants: 1

Tags for this Thread