Results 1 to 4 of 4

Thread: $_POST not working with grid paging?!?!?!

  1. #1

    Exclamation $_POST not working with grid paging?!?!?!

    I'm on the verge of going nuts here. I'm thinking there must be something wrong with my php.ini file but I don't know what it could be.

    Ok, I have a grid setup and working. It's using a php/mysql backend. I can get my data and populate my grid and that all works fine, however, I wanted to add pagination to the grid. Should be simple right? I got that all setup using the examples as guides. I'm using Firebug to see what is going on and when I load the page, Firebug is showing this as getting posted:

    limit 20
    start 0

    I couldn't get these values to show in my php script no matter what I tried. I tried post, get, request, globals, tried all sorts of stuff. I tried turning on register globals and then turning it back off. No dice no matter what I've tried. Right now I have a test php script in place while I try to figure out this issue and the script looks like this:

    Code:
    <?
    $start = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
    $limit = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']);
    
    print $start."<br>";
    print $limit."<br>";
    
    print_r($_POST);
    
    ?>
    Here is what Firebug shows as the response:
    Code:
    0<br>0<br>Array()
    I've searched these forums and Google and I have yet to find what could be causing this. I'm using PHP 5.2.1 on Ubuntu Feisty Fawn.

    Here is the js file I'm using:

    Code:
    Ext.onReady(function(){
    
        Ext.QuickTips.init();
        
        var xg = Ext.grid;
    
         var store = new Ext.data.Store({
         proxy : new Ext.data.HttpProxy({
         url: '/extjs/examples/grid/tng_people_grid.php'
       }),
       
       reader: new Ext.data.JsonReader({
       root: 'users',
       totalProperty: 'totalCount',
       id: 'ID'
       }, [
       
       {name: 'ID', mapping: 'ID', type: 'int'},
       {name: 'gedcom', mapping: 'gedcom', type: 'string'},
       {name: 'personID', mapping: 'personID', type: 'string'},
       {name: 'lnprefix', mapping: 'lnprefix', type: 'string'},
       {name: 'lastname', mapping: 'lastname', type: 'string'},
       {name: 'firstname', mapping: 'firstname', type: 'string'},
       {name: 'birthdate', mapping: 'birthdate', type: 'string'},
       {name: 'birthdatetr', mapping: 'birthdatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'sex', mapping: 'sex', type: 'string'},
       {name: 'birthplace', mapping: 'birthplace', type: 'string'},
       {name: 'deathdate', mapping: 'deathdate', type: 'string'},
       {name: 'deathdatetr', mapping: 'deathdatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'deathplace', mapping: 'deathplace', type: 'string'},
       {name: 'altbirthdate', mapping: 'altbirthdate', type: 'string'},
       {name: 'altbirthdatetr', mapping: 'altbirthdatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'altbirthplace', mapping: 'altbirthplace', type: 'string'},
       {name: 'burialdate', mapping: 'burialdate', type: 'string'},
       {name: 'burialdatetr', mapping: 'burialdatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'burialplace', mapping: 'burialplace', type: 'string'},
       {name: 'baptdate', mapping: 'baptdate', type: 'string'},
       {name: 'baptdatetr', mapping: 'baptdatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'baptplace', mapping: 'baptplace', type: 'string'},
       {name: 'endldate', mapping: 'endldate', type: 'string'},
       {name: 'endldatetr', mapping: 'endldatetr', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'endlplace', mapping: 'endlplace', type: 'string'},
       {name: 'changedate', mapping: 'changedate', type: 'date', dateFormat: 'm/d/Y'},
       {name: 'nickname', mapping: 'nickname', type: 'string'},
       {name: 'title', mapping: 'title', type: 'string'},
       {name: 'suffix', mapping: 'suffix', type: 'string'},
       {name: 'nameorder', mapping: 'nameorder', type: 'string'},
       {name: 'famc', mapping: 'famc', type: 'string'},
       {name: 'metaphone', mapping: 'metaphone', type: 'string'},
       {name: 'living', mapping: 'living', type: 'string'},
       {name: 'branch', mapping: 'branch', type: 'string'},
       {name: 'changedby', mapping: 'changedby', type: 'string'},
       {name: 'name', mapping: 'name', type: 'string'}
       ]),
    
       remoteSort: true
       });
    
        ////////////////////////////////////////////////////////////////////////////////////////
        // Grid 1
        ////////////////////////////////////////////////////////////////////////////////////////
        // row expander
        var expander = new xg.RowExpander({
            tpl : new Ext.Template(
                '<p><b>First Name:</b> {firstname}</p><br>',
                '<p><b>Last Name:</b> {lastname}</p>'
            )
        });
    
        var grid1 = new xg.GridPanel({
            store: store,
            cm: new xg.ColumnModel([
                expander,
       {
          header: 'Lastname, Given Name(s)',
          dataIndex: ('name'),
          sortable: true,
          width: 200 
       },
       {
          header: 'Birth Date',
          dataIndex: 'birthdate',
          sortable: true,
          width: 75 
       },
       {
             id: 'birthplace',
          header: 'Birth Place',
          dataIndex: 'birthplace',
          sortable: true,
          width: 30 
       },
       {
          header: 'Gender',
          dataIndex: 'sex',
          sortable: true,
          width: 50 
       },
        {
             header: 'Person ID',
          dataIndex: 'personID',
          sortable: true,
          width: 60 
       }   
            ]),
            
            bbar: new Ext.PagingToolbar({
                   pageSize: 20,
                   store: store,
                   displayInfo: true,
                   displayMsg: 'Displaying items {0} - {1} of {2}',
                   emptyMsg: "No items to display",
            }),
            width: 750,
            height: 500,
            plugins: expander,
            collapsible: false,
            pageSize: 25,
            autoExpandColumn: 'birthplace',
            animCollapse: false,
            title: 'Search Results',
            iconCls: 'icon-grid',
            renderTo: document.body
        });
    
        store.load({params:{start:0, limit:20}});
    });
    If this is something obvious that I'm just overlooking I'm going to feel pretty stupid but I'm stuck. Any ideas?

    EDIT: I forgot to mention that I did a simple html form and pointed it at the same php file and it works fine that way so $_POST works on my server when it's a regular html form but not when it's coming from EXT. Firebug shows identical info for what is getting posted but one http and one is xhtmlrequest or whatever it's called.

  2. #2

    Default

    you have not told the store to use a method other than the default (which is GET)...

  3. #3

    Default

    Quote Originally Posted by devnull View Post
    you have not told the store to use a method other than the default (which is GET)...
    Ya know, the odd thing is that I tried getting it with $_GET earlier... even tried printing out both $_POST and $_GET and neither worked. I just added the method param and now it's working though. Bizarre that I wasn't picking it up with $_GET but whatever.

    Thanks for the help!!!!

  4. #4
    Ext Premium Member
    Join Date
    Jan 2008
    Posts
    19

    Thumbs up Here is how it works!

    Hi Guys,

    Here is the trick. If you want to read $_POST variables then add 'method:POST' in your HttpProxy config. Moreover, if you want to add extra parameters like username etc then use baseParams with your store.

    Code:
    baseParams:{
                    start: 0,
                    limit: 25,                      
                    userName: 'sanjoy',
                    'task' : "testAccount"
              }
    You can configure your store as:

    Code:
    ds = new Ext.data.GroupingStore({ 
                proxy: new Ext.data.HttpProxy({                
                    url: 'processor.php', 
                    method: 'POST'
                }),   
               baseParams:{
                    start: 0,
                    limit: 25,                      
                    userName: 'sanjoy',
                    'task' : "testAccount"
              }, 
                reader: myReader,  //here is your JsonReader 
                sortInfo:{field: 'acc_username', direction: "ASC"}           
            });
    In processor.php you will write something like:
    PHP Code:
    $start      = (integer) (isset($_POST['start']) ? $_POST['start'] : $_GET['start']);
    $end        = (integer) (isset($_POST['limit']) ? $_POST['limit'] : $_GET['limit']); 
    $task       = ($_POST['task']) ? ($_POST['task']) : 'default';
    $username= ($_POST['userName']) ? ($_POST['userName']) : 'sanjoy'
    I hope this will help someone.
    Cheers!

Posting Permissions

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