1. #1
    Ext User
    Join Date
    Jul 2008
    Posts
    11
    Vote Rating
    0
    Akamy2kidsmom is on a distinguished road

      0  

    Default MemoryProxy need help with paging

    MemoryProxy need help with paging


    Hello,

    First, I am relatively new to ExtJS so please bear with me if I am asking a question that is obvious to most!

    I am currently developing a user defined query application that allows the user to select different combinations of fields from combos to dynamically build a custom query string to pass to the server. Once the user has the query entered to his/her liking, he pushes a search button that fires an event that dynamically loads a results grid.

    I am using a MemoryProxy for my datastore and calling an Ajax request via a POST to to pass my user query string to the sever and populate the datastore. My results are returning and displaying correctly, I just need to get paging to work. I don't want to go back to the server to query each time, so maybe a PagingMemoryProxy would work, but I'm not sure how to code it correctly.

    Here is my datastore and request to load code:
    Code:
    // Data store to hold the search results from the query
    this.searchResultsDS = new Ext.data.Store({
         proxy: new Ext.data.MemoryProxy(),
         reader: Resource.REaders.getReader('QuerySearchResults')
    });
    
    
    
    // Update data store with query search results
    updateDS : function (queryString) {
         var parentScope = this;
         // Go to the server to query and get the data
         Ext.Ajax.request({
              url: myURL,
              params: queryString,
              success: function (response, options) {
                   parentScope.searchResultsDS.proxy.data = response.responseXML;
                   parentScope.searchResultsDS.load();
              },
              failure: function (result, request) {
                    Ext.MessageBox.alert('Failed', result.responseText);
              }
         })
    }
    I have included a paging toolbar on my bbar of my grid with a pageSize of 25. My server side code only pulls the first 25 rows. This is the logic that is used for all of our other paging grids. The difference is that all of our other grids use an HttpProxy with a GET.

    If I use a PagingMemoryProxy, would I just return all rows back to my datastore? How do I setup the paging aspect then??

    Any help or suggestions would be greatly appreciated.

    Page

  2. #2
    Ext User
    Join Date
    Jul 2008
    Posts
    11
    Vote Rating
    0
    Akamy2kidsmom is on a distinguished road

      0  

    Default Resolved

    Resolved


    Just a note to let any other newbies know how we decided to handle this issue. Rather than use a MemoryProxy, we followed our same paradigm of using an HttpProxy and perform a query for each group of records that we want to display. There was a potential that thousands of records would be returned to our MemoryProxy, and we did not want to have that as an issue.

    For some reason, I was making the the HttpProxy with a POST more complicated than it really is. Once I played around with it a bit, I was able to get it to work correctly.

    Here is my what my data store and request to load currently looks like:
    Code:
    // Data Store to hold the search results from the query
    this.searchResultsDS = new Ext.data.GroupingStore({
         proxy: new Ext.data.HttpProxy({
              timeout: 120000,
              url: myURL,
              method: 'POST'
         }),
         reader: myReader,
         sortInfo: {field: 'fieldName', direction: "ASC"},
         groupField: 'fieldType'
    });
    
    
    
    
    // ****************************************
    // Update the data store with the query search results
    // The query search string is built on another panel and passed
    // into this grid to perform the actual query and display the results.
    updateDS : function(queryString) {
         var parentScope = this;
         parentScope.searchResultsDS.baseParams = {
              searchString: queryString
         };
         parentScope.searchResultsDS.load({params: {start: 0, limit: 25}});
    },
    Best wishes....it is getting easier thanks to so many great posts.

  3. #3
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Use a PagingMemoryProxy instead of a MemoryProxy.

Thread Participants: 1