Results 1 to 6 of 6

Thread: Grid Pagination with mvc framework

  1. #1

    Default Grid Pagination with mvc framework

    Hi...!

    i don't know if this is possible, and I have searched but could not find what I am looking for. Perhaps a kind soul would direct me to where I should be reading for my trouble.

    I have created a grid with pagination. I am trying this CodeIgniter framework and I like the URL parameters that follow the MVC rule! I mean I am trying to display data in a pagination form inside a grid and I am referencing the php function that returns a set of data in a certain page as follows:
    www.myweb.com/customers/list/10/3 (where 10 is the page size and 3 is the number of the page to be displayed).

    Now when I use the baseParams I take it that it sends the request as :
    http://www.myweb.com/customers/list/...0&pagenumber=3 When it does that my script no longer works. I don't really want to use the querystring format but rather the clean URL format such as the /10/3
    How can i do this with the grid data.stiore baseParams? Can this be done? Is there another avenue I should follow?

    Thank you kindly in advance...

    And have a stunning day!

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

    Default

    You can modify both the params and the url in the beforeload event of the proxy.

  3. #3

    Default

    hi Condor - thank you for the quick reply! If I am to understand correctly I should look into the beforeload event and build somehow the requested url and then send it through to the server? I mean construct a URL string from the baseParams details? Or am I somehow loosing myself into this whole thing?? hehehehehe

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

    Default

    Something like:
    Code:
    proxy: new Ext.data.HttpProxy({
    	url: 'http://www.myweb.com/customers/list/',
    	listeners: {
    		beforeload: function(proxy, params){
    			var pageSize = params.limit;
    			var currentPage = Math.floor(params.start / pageSize);
    			proxy.conn.url = 'http://www.myweb.com/customers/list/' + pageSize + '/' + currentPage;
    			delete params.start;
    			delete params.limit;
    		}
    	}
    })

  5. #5

    Default

    Oh man - you are a really amazing person - thank you! thank you!

  6. #6
    Sencha User
    Join Date
    Feb 2010
    Posts
    7

    Default

    I just spent most of the day working out how to achieve the same thing with mod_rewrite and then I came across Condor's solution. May as well post it as another option. It may be useful for moving existing client code to a MVC backend. Here's the .htaccess file I use for CodeIgniter serving to a paging grid.

    Code:
    RewriteEngine On
    RewriteBase /myapp
    
    #secure system folder
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #secure app folder
    RewriteCond %{REQUEST_URI} ^application.*
    RewriteRule ^(.*)$ /index.php?/$1 [L]
    
    #allow other files
    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^(.*)$ $1 [L]
    
    #Check for the start parameter
    RewriteCond %{QUERY_STRING} ^.*start=([0-9]+)&?.*$
    RewriteRule ^(.*)$ $1/%1 [DPI]
    
    #Check for the limit parameter
    RewriteCond %{QUERY_STRING} ^.*limit=([0-9]+)&?.*$
    RewriteRule ^(.*)$ $1/%1 [DPI] 
    
    #Check for the filter parameter
    RewriteCond %{QUERY_STRING} ^.*filter=([^&]+)&?.*$
    RewriteRule ^(.*)$ $1/%1 [DPI]
    
    #other parameters
    
    RewriteRule ^(.*)$ index.php?/$1 [L]

Posting Permissions

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