1. #1
    Sencha User
    Join Date
    Jul 2008
    Posts
    15
    Vote Rating
    0
    edema is on a distinguished road

      0  

    Default Answered: store.load({..}) ignore given params

    Answered: store.load({..}) ignore given params


    Hello I've a little problem, I've made a grid with a data store and when I try to load the store with some params the function ignore the given params.

    Example:
    I'm in the second page of the grid, the grid visualize page 2, records 48 of 48... if I call the function store.load({ params: { start: 0, limit: 9, page:0 }}), the store will be reloaded in page 2 whit the old limit instead of the given parameters. What can I do? It's my fault or that's something that I ignore?

    Here the code of my grid:

    Code:
    Ext.define('Ext.lazer.Grid', {
        extend: 'Ext.grid.Panel',
        id: 'lazer',
        iconCls: 'lazer-view',
        closable: true,
        viewConfig: {
            stripeRows: true
        },
        multiSelect: true,
        store: Ext.create('Ext.data.Store', {
            id: 'lazerStore',
            model: Ext.define('lazerModel', {
                extend: 'Ext.data.Model',
                fields: [{
                    name: 'id'
                }, {
                    name: 'hostname'
                }, {
                    name: 'ip'
                }, {
                    name: 'lazer_type'
                }, {
                    name: 'status'
                }, {
                    name: 'create_date',
                    type: 'date',
                    dateFormat: "d-m-Y"
                }, {
                    name: 'last_modify',
                    type: 'date',
                    dateFormat: "d-m-Y"
                }]
            }),
            pageSize: 25,
            autoLoad: false,
            remoteSort: true,
            proxy: {
                type: 'rest',
                url: '../ws/lazer.php',
                reader: {
                    type: 'json',
                    root: 'topics',
                    totalProperty: 'totalCount'
                }
            }
        }),
        initComponent: function () {
            if (!Ext.ModelManager.isRegistered('comboBoxModel')) {
                Ext.define('comboBoxModel', {
                    extend: 'Ext.data.Model',
                    fields: [{
                        type: 'string',
                        name: 'id'
                    }, {
                        type: 'string',
                        name: 'name'
                    }]
                })
            }
            Ext.apply(this, {
                columns: [{
                    text: "id",
                    sortable: true,
                    dataIndex: 'id',
                    hidden: true,
                    flex: 1
                }...bla.bla.bla...],
                bbar: Ext.create('Ext.PagingToolbar', {
                    id: 'archPaging',
                    store: this.store,
                    displayInfo: true,
                    displayMsg: 'Displaying lazer {0} - {1} of {2}',
                    emptyMsg: "No schedule to display"
                })
            });
            this.callParent(arguments);
        },
        listeners: {
            itemdblclick: { // old rowdbclick
                fn: function (grid, record) {
                    this.editlazer(record);
                }
            }
        },
        load: function () {
            this.store.load();
        },
        getId: function () {
            return this.id;
        },
        reloadMyGrid: function() { 
            this.store.load({params: {start: 0, limit: 9, page: 0}}); // This function doesn't work properly
        }
    });
    Thank you in advance, bye

  2. This is a community forum. While the Sencha developers do pop in occasionally it's unlikely they'd stumble across your post in amongst the dozens of others that come in every day.

    I don't much like that example in the docs. I suspect it works by co-incidence because the page size being passed in is the same as the page size on the store anyway. I think the following would work (note no params), though personally I'd still do it the way we've already discussed:

    Code:
    store.load({
        limit: 9,
        page: 1,
        start:0
    });
    I'll put in a request to get that example changed in the docs.

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,590
    Answers
    541
    Vote Rating
    322
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    What are you actually trying to do? Looks like you're trying to reload the store with a different page size?

    If all you want to do is reload the first page then use loadPage():

    http://docs.sencha.com/ext-js/4-0/#!...ethod-loadPage

  4. #3
    Sencha User
    Join Date
    Jul 2008
    Posts
    15
    Vote Rating
    0
    edema is on a distinguished road

      0  

    Default


    Thank you skirtle it works but, if I execute loadPage() with or without page number it work perfectly but if I do loadPage(1, {params: {limit: 2}}), the limit won't change. Why I can't change the number of displayed elements in grid? I've solved with a workaround (forcing the param store.pageSize= 2) but is very rude, If exists the function I want to use the function, if the function don't do the job I ask to the team to fix this problem.

  5. #4
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,590
    Answers
    541
    Vote Rating
    322
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    If you want to stick to documented methods then I think the only way to change the page size is to completely recreate the store. Setting the pageSize the way you have seems sensible to me.

  6. #5
    Sencha User
    Join Date
    Jul 2008
    Posts
    15
    Vote Rating
    0
    edema is on a distinguished road

      0  

    Default


    Ok skirtle your anwers are very useful however this is a piece of code provided in the Extjs4 API at this link http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.Panel

    Code:
    var itemsPerPage = 2;   // set the number of items you want per page
    
    var store = Ext.create('Ext.data.Store', {
        id:'simpsonsStore',
        autoLoad: false,
        fields:['name', 'email', 'phone'],
        pageSize: itemsPerPage, // items per page
        proxy: {
            type: 'ajax',
            url: 'pagingstore.js',  // url that will load data with respect to start and limit params
            reader: {
                type: 'json',
                root: 'items',
                totalProperty: 'total'
            }
        }
    });
    
    
    // specify segment of data you want to load using params
    store.load({
        params:{
            start:0,
            limit: itemsPerPage
        }
    });
    
    
    Ext.create('Ext.grid.Panel', {
        title: 'Simpsons',
        store: store,
        columns: [
            {header: 'Name',  dataIndex: 'name'},
            {header: 'Email', dataIndex: 'email', flex:1},
            {header: 'Phone', dataIndex: 'phone'}
        ],
        width: 400,
        height: 125,
        dockedItems: [{
            xtype:http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store 'pagingtoolbar',
            store: store,   // same store GridPanel is using
            dock: 'bottom',
            displayInfo: true
        }],
        renderTo: Ext.getBody()
    });
    There is a part where the code says: store.load({ params ...... why this feature don't work? The question is addressed to the sencha developers/admin or whatever. Thank you!

  7. #6
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,590
    Answers
    541
    Vote Rating
    322
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    This is a community forum. While the Sencha developers do pop in occasionally it's unlikely they'd stumble across your post in amongst the dozens of others that come in every day.

    I don't much like that example in the docs. I suspect it works by co-incidence because the page size being passed in is the same as the page size on the store anyway. I think the following would work (note no params), though personally I'd still do it the way we've already discussed:

    Code:
    store.load({
        limit: 9,
        page: 1,
        start:0
    });
    I'll put in a request to get that example changed in the docs.

  8. #7
    Sencha User
    Join Date
    Jul 2008
    Posts
    15
    Vote Rating
    0
    edema is on a distinguished road

      0  

    Default


    No one have another solution?

  9. #8
    Sencha User
    Join Date
    Sep 2010
    Location
    Germany
    Posts
    53
    Answers
    2
    Vote Rating
    2
    HTK is on a distinguished road

      0  

    Default


    I do also use load without PARAMS object. It works for me.

  10. #9
    Sencha User
    Join Date
    Jul 2008
    Posts
    15
    Vote Rating
    0
    edema is on a distinguished road

      0  

    Default


    Ok thanks

Thread Participants: 2