1. #1
    Sencha User samarulraj's Avatar
    Join Date
    Aug 2013
    Location
    India
    Posts
    12
    Vote Rating
    0
    samarulraj is on a distinguished road

      0  

    Default Ext Js Paging for Grid panel not works with Ext Direct

    Ext Js Paging for Grid panel not works with Ext Direct


    Hi Team ,

    I am new to the development of Ext Direct. i found some tutorials and updated my code to connect with the PHP . here is my users.js
    Code:
    Ext.require(['Ext.direct.*', 'Ext.data.*', 'Ext.grid.*', 'Ext.util.Format']);
    
    
    Ext.define('Users', {
        extend : 'Ext.data.Model',
        fields : ['name', 'email', 'company', 'phone', 'city']
    });
    
    
    Ext.onReady(function() {
        Ext.direct.Manager.addProvider(Ext.app.REMOTING_API);
    
    
        
    var store = Ext.create('Ext.data.Store', {
                   model : 'Users',
                   remoteSort : true,
                autoLoad : true,
                pageSize: 5, // items per page
                totalProperty:'total',
                sorters : [{
                    property : 'name',
                    direction : 'ASC'
                }],
                proxy : {
                    type : 'direct',
                    directFn : 'Users.showAllUsers'
                
                }
    });
    
    
    
    
        // create the Tree
        Ext.create('Ext.grid.Panel', {
            store : store,
            columns : [{
                dataIndex : 'name',
                flex : 1,
                text : 'Name'
            }, {
                dataIndex : 'email',
    
    
                width : 120,
                text : 'Email'
    
    
            }, {
                dataIndex : 'company',
    
    
                text : 'Company'
    
    
            }, {
                dataIndex : 'phone',
    
    
                text : 'Phone'
    
    
            }, {
                dataIndex : 'city',
    
    
                text : 'City'
    
    
            }],
            
             dockedItems: [{
                xtype: 'pagingtoolbar',
                store: store,   // same store GridPanel is using
                dock: 'bottom',
                
                displayInfo: true
            }],        
                        
            height : 350,
            width : 600,
            title : 'Users',
            renderTo : Ext.getBody()
        });
        
        
    
    
        
    });

    I added paging to the grid panel. i call the ext dirct via directFn proxy. i get all the datas loaded into the grid panel.this is my users.php

    Code:
    function showAllUsers($params)
        {
            $sort = $params->sort[0];
                  $field = $sort->property;
                  $direction = $sort->direction;
            $start = $params->start;
            $end = $params->limit;
            
            ($direction == 'ASC' ? 'ASC' : 'DESC');
            
            $dbh = Dbconfig::dbconnect();
            $sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction");
            $sth->execute();
            $data = $sth->fetchAll();
            
            return $data;
        }

    while clicking on the next button that loads all the values again . i dunno what to do next.
    Attached Images

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You sql call is this:

    Code:
    $sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction");
    but you are not handling the start and limit params at all.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User samarulraj's Avatar
    Join Date
    Aug 2013
    Location
    India
    Posts
    12
    Vote Rating
    0
    samarulraj is on a distinguished road

      0  

    Default Start and LIMIT added to query

    Start and LIMIT added to query


    Hi Sir,

    I have used this also when i add $start and $limit variables in my query
    I receive only Five records. there is no next move for the next page to load other data .
    the pagination disabled within one page.to propagate to next page. what do i need to do?

    Thanks in advance
    my query : $sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction LIMIT $start,$end");
    totally i have 47 records inside

    my response header:
    header.jpg

    third.PNG

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Your response needs to pass the total number of records and therefore your reader also needs to be modified. The response needs to look something like this:

    Code:
    {
        "success" : true,
        "total"   : 100,
        "data"    : [
            {},
            {},
            {}
        ]
    }
    The "total" is the total number of records, the "data" is the array of data like you are currently returning. Then your reader needs to have the root config set to "data"
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User samarulraj's Avatar
    Join Date
    Aug 2013
    Location
    India
    Posts
    12
    Vote Rating
    0
    samarulraj is on a distinguished road

      0  

    Default


    in my proxy what do i need to add here
    Code:
    proxy : {              
     type : 'direct',                
    directFn : 'Users.showAllUsers' 
              }
    since it is type direct

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Ok, so all you would have to do is edit it to be like this:

    Code:
    proxy : {
        type : 'direct',	
        directFn : 'Users.showAllUsers' ,
        reader : {
            root : 'data'
        }
    }
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  7. #7
    Sencha User samarulraj's Avatar
    Join Date
    Aug 2013
    Location
    India
    Posts
    12
    Vote Rating
    0
    samarulraj is on a distinguished road

      0  

    Default Still i get this same error

    Still i get this same error


    how to set the totalProperty, since i tried from reader i unable to do it

    still5.jpg

  8. #8
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Your response needs to be changed, please see my last reply on an example that it should look like.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  9. #9
    Sencha User samarulraj's Avatar
    Join Date
    Aug 2013
    Location
    India
    Posts
    12
    Vote Rating
    0
    samarulraj is on a distinguished road

      0  

    Default Proxy root added

    Proxy root added


    I added Proxy

    Code:
    var store = Ext.create('Ext.data.Store', {
       			model : 'Users',
       			remoteSort : true,
    			autoLoad : true,
    			pageSize: 5, // items per page
    			
    			sorters : [{
    				property : 'name',
    				direction : 'ASC'
    			}],
    			totalProperty:'total',
    			proxy : {
    				type : 'direct',
    				directFn : 'Users.showAllUsers',
    				reader: {
    				       
    				        root: 'data'
    				      
    				       
       				}
    				/*api: {
    					create:	Users.addUsers,
    					read: Users.showAllUsers,
    					update:	Users.editUsers,
    					destroy: Users.deleteUsers
    				},*/
    			
    				
    			
    			}
    });
    my query is same as follows

    Code:
    $sth = $dbh->prepare("SELECT * FROM users ORDER BY name $direction LIMIT $start,$end");
    		$sth->execute();
    		$data = $sth->fetchAll();
    	
            return $data;
    that return only 5 data according to limit

    Response
    checked.jpg

  10. #10
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    751
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You aren't changing your response, that is the key. It needs to be an object like my example above not an array.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar