Results 1 to 2 of 2

Thread: extend store

  1. #1

    Default extend store

    I know English is bad, so I use a translator.

    create a new class 2 store:
    Code:
    Ext.define("Ext.data.Store2",
        {
        extend: 'Ext.data.Store',
        idProperty: 'id',
        remoteSort: true,
        proxy:
            {
            type: 'ajax',
            actionMethods:
                {
                read: 'POST'
                },
            reader:
                {
                root: 'data',
                totalProperty: 'totalCount'
                },
            simpleSortMode: true
            },
        sorters: [
            {
            property: 'id',
            direction: 'ASC'
            }],
        
        constructor: function(config)
            {
            this.proxy.url = config.url;
            Ext.data.Store2.superclass.constructor.call(this, config);
            }
        });
    create and store:
    Code:
    var store1 = Ext.create("Ext.data.Store2",
        {
        pageSize: 20,
        fields: ['id', 'name'],
        url: 'data1.php',
        autoLoad: true,
        listeners:
            {
            load:
                {
                fn: function()
                    {
                    console.log(this.model.modelName);
                    console.log(this.data.items[0].id);
                    console.log(this.data.items[0].data);
                    }
                }
            }
        });    
        
    var store2 = Ext.create("Ext.data.Store2",
        {
        pageSize: 20,
        fields: ['id', 'datetime_create'],
        url: 'data2.php',
        autoLoad: true,
        listeners:
            {
            load:
                {
                fn: function()
                    {
                    console.log(this.model.modelName);
                    console.log(this.data.items[0].id);
                    console.log(this.data.items[0].data);
                    }
                }
            }
        });
    the result will be as follows:

    Ext.data.Store.ImplicitModel-ext-gen1022 settings.js:345
    Ext.data.Store.ImplicitModel-ext-gen1021-1 settings.js:346
    Object {id: "1", name: ""} settings.js:347
    Ext.data.Store.ImplicitModel-ext-gen1021 settings.js:325
    Ext.data.Store.ImplicitModel-ext-gen1021-1 settings.js:326
    Object {id: "1", name: "google"}

    it is not the result I expected.
    in the second case, the fields do not take those. takes from the first store. how to write this code?

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505

    Default

    In my testing this looks to be working ok. See the example below tested with ExtJS 4.2.1:

    https://fiddle.sencha.com/#fiddle/1p4

Posting Permissions

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