1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    43
    Answers
    1
    Vote Rating
    0
    indapublic is on a distinguished road

      0  

    Default Unanswered: Nested List & Pull Refresh

    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 - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,330
    Answers
    3541
    Vote Rating
    847
    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


    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 @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
    Touch Premium Member
    Join Date
    Feb 2011
    Posts
    57
    Vote Rating
    0
    mvoss is on a distinguished road

      0  

    Default Reloading part of treestore

    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
    mvoss is on a distinguished road

      0  

    Default working

    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);
                }
            });
        }
    });

Thread Participants: 2