Results 1 to 7 of 7

Thread: DirectStore and server-side paging

  1. #1
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default DirectStore and server-side paging

    How to implement server-side paging in a GridPanel using DirectStore? start and limit parameters are not passed to the server with direct request. Am I missing something?

    Here's my extension:
    PHP Code:
    Ext.ux.AuthorsGrid Ext.extend(Ext.grid.GridPanel, {

        
    initComponent: function() {
            var 
    ds = new Ext.data.DirectStore({
                
    directFnPubs.GetAuthors,
                
    paramsAsHashfalse,
                
    root'authors',
                
    idProperty'au_id',
                
    totalProperty'total',
                
    sortInfo: {
                    
    field'au_id',
                    
    direction'ASC'
                
    },
                
    fields: [
                    
    'au_id''au_lname''au_fname''phone''address''city''state''zip',
                    {
    name'contract'type'boolean'}
                ]
            });
            
            var 
    pager = new Ext.PagingToolbar({
                
    storeds,
                
    displayInfotrue,
                
    pageSize10
            
    });
            
            var 
    config = {
                
    storeds,
                
    columns: [
                    {
    header'ID'dataIndex'au_id'},
                    {
    header'First Name'dataIndex'au_fname'},
                    {
    header'Last Name'dataIndex'au_lname'},
                    {
    header'Phone'dataIndex'phone'},
                    {
    header'Address'dataIndex'address'},
                    {
    header'City'dataIndex'city'},
                    {
    header'State'dataIndex'state'},
                    {
    header'Zip'dataIndex'zip'}
                ],
                
    bbarpager
            
    };
            
    Ext.apply(thisExt.apply(this.initialConfigconfig));
            
            
    Ext.ux.AuthorsGrid.superclass.initComponent.apply(thisarguments);
        },
        
        
    afterRender: function() {
            
    this.getStore().load();
            
            
    Ext.ux.AuthorsGrid.superclass.afterRender.apply(thisarguments);
        }
    });

    Ext.reg('authorsgrid'Ext.ux.AuthorsGrid); 

  2. #2
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    PagingToolbar will pass the params as defined in paramNames of the PagingToolbar.

    Since you have paramsAsHash set to false; you will need to specify an order of the arguments which are going to be passed to your function such as:
    Code:
    paramOrder: 'start|limit'
    What does your server-side method signature look like? Could you post a capture of the POST for both the initial load and after you click on the paging toolbar?
    Aaron Conran
    @aconran

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default

    Quote Originally Posted by aconran View Post
    PagingToolbar will pass the params as defined in paramNames of the PagingToolbar.

    Since you have paramsAsHash set to false; you will need to specify an order of the arguments which are going to be passed to your function such as:
    Code:
    paramOrder: 'start|limit'
    What does your server-side method signature look like? Could you post a capture of the POST for both the initial load and after you click on the paging toolbar?
    My server-side signature was wrong. I changed it to:
    Code:
    GetAuthors(int start, int limit)
    and it works fine now.

    And of course paramOrder need to be specified.

    BTW, not having paramOrder and setting paramsAsHash to false causes a serious problem in RC2. Too much recursion. Just FYI.

    I will test against SVN on the weekend.

    Thanks a lot for help!

  4. #4
    Sencha User
    Join Date
    Jan 2008
    Location
    Toronto, Canada
    Posts
    481

    Default

    And of course I had to change the way initial load is done:

    PHP Code:
    afterRender: function() {
        
    this.getStore().load({
            
    params: {
                
    start0,
                
    limit10
            
    }
        });
        
        
    Ext.ux.AuthorsGrid.superclass.afterRender.apply(thisarguments);


  5. #5
    Sencha User j.bruni's Avatar
    Join Date
    Jun 2009
    Location
    Uberlndia, MG, Brazil
    Posts
    106

    Default Thanks

    This thread helped me on this:
    http://extjs.com/forum/showthread.php?p=348304

    I had a hard time to pass an extra parameter to do Updates...

    I found no way to add a "table" parameter when using autoSave... even using the "beforewrite" event...

    DataProxy#doRequest puts the "idProperty"'s value and the modified record's data as the two parameters to the update request... ignores baseParams... and do not add any other parameter to the remote function call... it ignores paramOrder and paramsAsHash...

    My workaround was to turn autoSave off (to avoid recursion) and manually add the extra parameter as a field in the record set, in the EditorGrid#afterEdit event.

    This field was created only for sending the extra parameter... it is "fictional", meaning that it does not exist in the remote database.

    Code:
    onAfteredit: function( e ) {
        var table = this.baseParams.table;
        e.record.set( 'pmea_table', table );
        this.save();
      }
    Anyway... I am happy that somehow I could send my third parameter to the remote update function!

    Thanks!

  6. #6
    Sencha User
    Join Date
    Feb 2009
    Posts
    38

    Default return object

    Thanks, it is working to me also
    but what is the return object from server means data + total number of records ?

  7. #7

    Default

    Hi All,

    I have one question over here.

    for paging, we need to have data in the following format.
    { "success": true, "results": 2000, "rows": [ // *Note: this must be an Array { "id": 1, "name": "Bill", "occupation": "Gardener" }, { "id": 2, "name": "Ben", "occupation": "Horticulturalist" }, ... { "id": 25, "name": "Sue", "occupation": "Botanist" } ] Can anybody please let me know how success property is handled. Can we make property to show any custom error message? Also how should we handled pagination in case of server API failure.

Posting Permissions

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