Results 1 to 8 of 8

Thread: GridPanel limit results

  1. #1

    Default GridPanel limit results

    Hi !

    I just can't figure out what's wrong. I just can't make my data store returns just the number of row that I need... I tried a few options, but none of them works, it always gives me the full resultset.

    Do I have to do something on server-side (in my WCF service) ?

    Code:
    Ext.onReady(function() {
    
        var personne = Ext.data.Record.create([
            { name: 'nom' },
            { name: 'prenom' }
        ]);
    
        var myReader = new Ext.data.JsonReader({
            totalProperty: "total",
            root: "list"
    
        }, personne
        );
    
        var myProxy = new Ext.data.HttpProxy({
            url: 'http://localhost:1041/Person.svc/Get',
            method: 'POST'
            //params: {}
        });
    
        var store = new Ext.data.Store(
            {
                proxy: myProxy,
                reader: myReader
    
            }
        );
    
        var pagingToolbar = {
            xtype: 'paging',
            store: store,
            pageSize: 5,
            displayInfo: true
        }
    
        var gr = new Ext.grid.GridPanel({
            el: 'grid', //div dans la quelle le GridPanel sera dessin
            viewConfig: { //Fait en sorte que la somme des largeurs de colonnes soit gale  la taille de la grille
                forceFit: true
            },
            ds: store, // la source de donnes
            bbar: pagingToolbar,
            cm: new Ext.grid.ColumnModel([ //Dfinit les colonnes du tableau et le mapping avec les champ du Record
                {header: "Nom", width: 120, sortable: true, dataIndex: 'nom' },
                { header: "Prenom", width: 100, sortable: true, dataIndex: 'prenom' }
            ]),
            sm: new Ext.grid.RowSelectionModel({ singleSelect: true }), // Politique de slction de ligne (Slection simple)
            width: 600, //largeur de la grille
            height: 300, //hauteur de la grille
            frame: true, //dessine la grille avec un contour arrondit
            title: 'Grid Panel Example' //titre de la grille
    
        });
    
            //Afficher la grille
            gr.render();
            //Charger les donnes
            store.load({});
    //        store.load({ // 2
    //            params: {
    //                start: 0,
    //                limit: 5
    //            }
    //        });
    
        });

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    You are using remote paging, so Ext expects the server to return the correct records for the specified 'start' and 'limit' parameters.

    ps. If you want local paging then you should use the PagingStore user extension.

  3. #3

    Default

    Ok, thanks ! Now I just have to understand how to pass parameters to a .NET WCF service... Tried everything, but nothing seems to work. Not even if I just try the start and limit parameters...

    Thanks a lot !

  4. #4

    Default

    Add this to your store definition?

    Code:
    new Ext.data.Store({
      ...
      baseParams: {
        'start': '',
        'limit': '5'
      },
      ...
    })
    Wes

  5. #5
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    No, that is wrong.

    start and limit (and sort and dir) shouldn't be in baseParams. For paging, any other param should indeed go into baseParams.

    For start and limit you should use:
    Code:
    autoLoad: {params: {start: 0, limit: 5}}
    or simply
    Code:
    store.load({params: {start: 0, limit: 5}});

  6. #6

    Default

    @Condor: What makes it wrong? store.load(); seems quicker to write, read, and maintain than store.load({params: {start: 0, limit: 5}}); I'm not trying to pick, I am concerned that my projects are going to fall victim to something I didn't consider before (that my baseParams aren't working properly).
    Wes

  7. #7
    Sencha Premium Member steffenk's Avatar
    Join Date
    Jul 2007
    Location
    Haan, Germany
    Posts
    2,675

    Default

    i don't get it too. You even can override baseParams with params in load call if you want. At the end it's merged
    Code:
    Ext.applyIf(options.params, this.baseParams);
    vg Steffen
    --------------------------------------
    Release Manager of TYPO3 4.5

  8. #8
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Yes, it works, but IMHO 'dynamic' parameters like 'start', 'limit', 'sort' and 'dir' don't belong in the 'static' baseParams.

Similar Threads

  1. How do I limit results from my dataStore?
    By kspratling in forum Ext 3.x: Help & Discussion
    Replies: 3
    Last Post: 12 Mar 2010, 3:16 AM
  2. Populate gridpanel from formpanel search results
    By dbinaz in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 30 Aug 2009, 7:53 AM
  3. GridPanel - Select All Results / All Pages
    By Clever Cutter in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 12 Mar 2009, 1:38 PM
  4. Limit row height in GridPanel
    By mikhailt in forum Ext 2.x: Help & Discussion
    Replies: 2
    Last Post: 9 Oct 2008, 11:13 AM
  5. limit in BasePagingLoader
    By Orion- in forum Ext GWT: Help & Discussion (1.x)
    Replies: 0
    Last Post: 30 May 2008, 7:02 AM

Posting Permissions

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