1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    52
    Vote Rating
    0
    rich_montana is on a distinguished road

      0  

    Default Paging and Sorting grids...

    Paging and Sorting grids...


    Hi. I experiencing some confusion when sorting and paging of a grid in regards to what to send and what to receive. I am able to send out a request and populate the grid that has a paging toolbar and allows for columns to be sortable. However the mechanics of the sorting and paging do not work.

    One of my confusions is what exactly is supposed to be happening. When i press over to page the next set of results should a request being going to the service dictating the limit and start OR should the javascript be doing that locally and saving a request from being sent by managing which rows to show within the grid. It appears to me that a request is being sent everytime. Personally this doesn't bother too much but knowing how that works would help.

    If a request is sent every time how do i get the values of the current start position? ie if was on the second page and the limit was 25 that once the over page button was pressed that the next start position was 75? Using firebug it seems to me these params are sent but the service i use accepts xml in the content body of the request to formulate a reply. this being said i have a function that is called to return the xml for the params field of the data store. the function prior to adding paging to the grid was:
    PHP Code:
    SorApp.getRequestXML = function(){
       if (Ext.get('fname') == null ) {
                $requestXML = '';    
       } else {                
            var requestXML = 
                    "<?xml version='1.0' encoding='UTF-8'?>"+
                    "<createEntireTree>Yes</createEntireTree>"+
                    "<name_first>" + Ext.get('fname').dom.value + "</name_first>"+
                    "<name_last>" + Ext.get('lname').dom.value + "</name_last>"+
                    "<dob>" + Ext.get('dob').dom.value + "</dob>"+
                    "<ssn>" + Ext.get('ssn').dom.value + "</ssn>"+
                    "<gender>" + Ext.get('gender').dom.value + "</gender>";
            //    alert(requestXML);
        }
        return requestXML;
    }
    To add paging and have the correct params being sent over i would expect the function to be somewhat like:

    PHP Code:
    SorApp.getRequestXML = function(){

      if (Ext.get('fname') == null ) {
                $requestXML = '';    
        } else {                
            var requestXML = 
                    "<?xml version='1.0' encoding='UTF-8'?>"+
                    "<start>" + start + "</start>" +    
                    "<limit>" + limit + "</limit>" +     
                    "<createEntireTree>Yes</createEntireTree>"+
                    "<name_first>" + Ext.get('fname').dom.value + "</name_first>"+
                    "<name_last>" + Ext.get('lname').dom.value + "</name_last>"+
                    "<dob>" + Ext.get('dob').dom.value + "</dob>"+
                    "<ssn>" + Ext.get('ssn').dom.value + "</ssn>"+
                    "<gender>" + Ext.get('gender').dom.value + "</gender>";
            //    alert(requestXML);
        }
        return requestXML;
    }
    But do not know how to get the limit and the start for the current page.

    Also w/ sorting of columns i was planning on adding the following to the function above:
    PHP Code:
    "<sort_by>" sort_by "</sort_by>" 
    But again how to get the sort by?

    All comments are welcomed and greatly appreciated!

    THANKS,
    RICH

  2. #2
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    All in the FAQs my dear man. There's a section dedicated to grids, and within that sections on paging and sorting.

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    52
    Vote Rating
    0
    rich_montana is on a distinguished road

      0  

    Default


    while i didnt want to have to change server code to examine post params as i was using the xml in the content body i now submitting to that i suppose.

    one problem i am experiencing is that my start value is constantly: "NaN" This naturally is causing problems in the server code. my total number of rows is correct and the total number of pages needed to encompass all those rows based on my limit is correct. but this is only in the toggle area not the totals area. so why the start is off is beyond me.

    ie currently there are 75 rows getting turned back so on my bottom toolbar i see:

    "page NaN of 3 .... Displaying NaN - NaN of 75 rows"

    i am pretty much directly using the paging code in:
    http://extjs.com/deploy/dev/examples/grid/paging.js

    So i am guessing there is something am failing to return back from the server? The FAQs fail to mention what exactly the server should send back so the toolbar can work properly.

    However the FAQs about paging have the following 2 lines that are of importance:
    To get the start for the currently displayed page try using pagingToolBar.cursor.
    To get the page number: start / limit + 1 = page number
    Question then is how do i use this to set values in the toolbar?

  4. #4
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Might help someone help you if you post your grid code?

  5. #5
    Ext User
    Join Date
    Apr 2008
    Posts
    52
    Vote Rating
    0
    rich_montana is on a distinguished road

      0  

    Default


    Ive just about got this one wrapped up. my problem above was not including start and limit in the params for the data store load. my last remaining problem i believe is that when pressing the over page button is sent, the xmlData isnt set. my params are set as such:
    PHP Code:
     params: {start:0,limit:25,xmlData:SorApp.getRequestXML()} 
    To properly format my query i xmlData has to be set and sent on every request.

    The below code is code regarding the toolbar:

    PHP Code:
    SorApp.SorToolbar Ext.extend(Ext.PagingToolbar,{
        
    initComponent : function(){
            
    Ext.apply(this, {
                
    pageSize25,
                
    storeExt.StoreMgr.get('gridSorStore'),
                
    displayInfotrue,
                
    emptyMsg"No one to display",
                
    displayMsg'Displaying {0} - {1} of {2}'

            
    });
            
    SorApp.SorToolbar.superclass.initComponent.call(this);
        }
    }); 
    ...
    PHP Code:
    SorApp.SorGrid Ext.extend(Ext.grid.GridPanel, {
        
    // override 
        
    initComponent : function() {
            
    Ext.apply(this, {
            
    cmcolModel,
            
    sm: new Ext.grid.RowSelectionModel({singleSelecttrue}),
            
    bodyStyle'padding:5px 5px 0',
            
    stripeRowstrue,
            
    loadMask:({
                
    msg"Searching..."
            
    }),
            
    store: new SorApp.SorStore({
                
    storeId'gridSorStore',
                
    proxy: new Ext.data.HttpProxy({
                   
    url'URL',
                   
    method'post',
                   
    params: {start:0,limit:25,xmlData:SorApp.getRequestXML()}
                 }),
            }),
            
    bbar: new SorApp.SorToolbar()
            });
        
    SorApp.SorGrid.superclass.initComponent.call(this);
        }
    });
    Ext.reg('sorgrid'SorApp.SorGrid); 
    thanks
    --RICH

  6. #6
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996
    Vote Rating
    5
    mjlecomte will become famous soon enough mjlecomte will become famous soon enough

      0  

    Default


    Re-read the FAQ: http://extjs.com/learn/Ext_FAQ_Grid#...l_record_count

    I tried to clean it up further and address your issues better.

    Look at baseParams or use
    Code:
    store.load({//put your params here});
    Your problem area:
    Code:
        params: {start:0,limit:25,xmlData:SorApp.getRequestXML()}

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi