Results 1 to 4 of 4

Thread: Nested List & Pull Refresh

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    61
    Answers
    1
    Vote Rating
    0
      0  

    Default Unanswered: Nested List & Pull Refresh

    Can I use plugin Pull Refresh for Nested List (or simulate it)?
    I know that Nested List is not reload, but I want catch event and reload list's store.

  2. #2
    Sencha - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,326
    Answers
    3884
    Vote Rating
    1297
      0  

    Default

    It won't just be plug and play, you would need to override it to reload the treestore which is not optimal. You can do an Ajax request and then remove the children from a node and then add children (and their children) to that node.
    Mitchell Simoens @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
    Touch Premium Member
    Join Date
    Feb 2011
    Posts
    57
    Vote Rating
    0
      0  

    Default Reloading part of treestore

    Hi,

    I need this in my application. I have currently overriden the fetchLatest function in the Ext.plugin.PullRefresh class. My plan is then to do my own reload of the data. My Treestore has a ajax proxy which loads nodes child nodes when clicked on them (with the node parameter). But how can i only reload one part of the tree? I tried this:

    Code:
    myStore.load({
                node: mySelectedNode
            });
    mySelectedNode is the currently selected node in the tree. But after the refresh the list is empty and the emptytext is shown. Any ideas?

  4. #4
    Touch Premium Member
    Join Date
    Feb 2011
    Posts
    57
    Vote Rating
    0
      0  

    Default working

    Hi,

    I got this to work with the code below. Basically I am doing a ajax request getting the new nodes, and inserting them into the active lists store. The trick is really to set the parentNode on the newly created model instances. As well as firing a datarefresh event on the store. This works for me. If there are any easier ways of doing this, let me know

    Code:
    Ext.define('myApp.ux.PullRefresh', {     extend: 'Ext.plugin.PullRefresh',
         fetchLatest: function(){
            var me = this;
            var store = me.getList().getStore();
            Ext.Ajax.request({
                url: "URL"
                success: function(response) {
                    var jsonData = Ext.decode(response.responseText);
                    var newRecords = new Array();
                    var store = me.getList().getStore();
                    Ext.each(jsonData.objects, function(el, index) {
                        var modelInst = Ext.create(store.getModel(), el);
                        modelInst.parentNode = store._node;
                        newRecords.push(modelInst);
                    }, this);
    
    
                    var operation = Ext.create('Ext.data.Operation', {
                        model: store.getModel(),
                        limit: store.getPageSize(),
                        action: 'read',
                        sorters: store.getSorters(),
                        filters: store.getRemoteFilter() ? store.getFilters() : []
                    });
                    operation.setRecords(newRecords);
                    store.fireAction('datarefresh', [store, store.data, operation], 'doDataRefresh');
                    me.onLatestFetched(operation);
                }
            });
        }
    });

Posting Permissions

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