Model view controller 追加到列表在拉入刷新时不更新

Model view controller 追加到列表在拉入刷新时不更新,model-view-controller,sencha-touch-2,pull-to-refresh,Model View Controller,Sencha Touch 2,Pull To Refresh,我对ST还是新手,所以我可能在这里做了一些错误的事情,但我不知道问题出在哪里 问题1 当我使用pull刷新插件时,我会得到双倍的数据,而不是仅仅刷新数据。我见过使用propertyId,所以我没有用。这应该很简单,所以我可能做错了一些愚蠢的事情 问题2 我试图找出使用MVC架构的最有效的方法,我已经阅读了文档和许多示例。所以,我不知道我是不是理解得不清楚,还是需要一个更好的例子。我现在正在尝试创建一个简单的应用程序,其中包含一个列表,我可以点击一个项目并获得该项目的详细视图。稍后我会把它进化成一

我对ST还是新手,所以我可能在这里做了一些错误的事情,但我不知道问题出在哪里

问题1 当我使用pull刷新插件时,我会得到双倍的数据,而不是仅仅刷新数据。我见过使用propertyId,所以我没有用。这应该很简单,所以我可能做错了一些愚蠢的事情

问题2 我试图找出使用MVC架构的最有效的方法,我已经阅读了文档和许多示例。所以,我不知道我是不是理解得不清楚,还是需要一个更好的例子。我现在正在尝试创建一个简单的应用程序,其中包含一个列表,我可以点击一个项目并获得该项目的详细视图。稍后我会把它进化成一个更健壮的怪物,但现在我正在努力理解它的基本原理。当我点击一个列表项时,我终于得到了关闭按钮来关闭细节视图,但是当点击另一个项目时,我再也无法获得细节视图。我已经读到这是由于“自动销毁:关闭”不存在,但我尝试了,也没有运气。我希望能够创建某些按钮,如“关闭”,我可以将其放在多个视图中,并且只需要在控制器中具有逻辑

主视图

贮藏

控制器获取详细视图

按钮控制器暂时关闭

模型


我知道这是很多,但任何帮助都是非常感谢的…即使是朝着正确的方向轻推。提前谢谢!此外,我确信其中有些东西不需要,因为我很难找到我想要完成的事情的好例子,所以我从不同的例子中找到了一些片段,我试图一起玩得很好:

我通过将idProperty更改为“id”并将其放在我的模型字段列表中,解决了刷新问题。我仍然不确定为什么“DistrID”不起作用,但我的脚本中有一个“id”字段,它包含我不知道的服务器响应,因为我没有编写该部分。所以,我不得不猜测这就是它不起作用的原因

我曾读到“autoDestroy:false”是允许再次单击所需的,但这是错误的。当我取出该属性时,它允许我继续打开和关闭列表项的详细信息

现在,我只需要传递单击列表项的id,以获得该特定项的详细视图。如果有人能帮上忙,那就太好了,否则我会发布一个新问题。谢谢

我想出了如何获取列表项id,以防它可以帮助任何人。。。 在我的DistributorController中,我只需获取存储和记录id

var store = Ext.getStore('NodeStore');
            var id = record.get('id');
然后设置参数并加载存储

store.getProxy().setExtraParams({id: id});
            store.load();
我也发现你不能通过控制器引用你的商店。而是像我上面使用var store=Ext.getStore'StoreName'那样获取存储;
这都是非常简单的东西,但我仍然非常了解,所以也许它可以帮助解决另一个n00b问题

您可以添加您的商店定义吗?它当前具有SenchaFirstApp.view的代码。DistributorView@Dave巴克,我道歉。我以为我有它,但又添加了我的观点来代替商店。现在就在那里,谢谢你的回复。这个url是我刚刚在某个地方找到的,在我的列表中有空数据。我正在用实际数据建立一个文件。
Ext.define('SenchaFirstApp.store.DistributorStore', {
                        extend: 'Ext.data.Store',
                        requires: ['SenchaFirstApp.model.Distributors'],

                        config: {
                        //  xtype: 'distrlist',
                            storeId: 'DistrID',
                        model: 'SenchaFirstApp.model.Distributors',
                        autoLoad: true,
                        proxy: {
                            type: 'jsonp',
                            url:'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://gdata.youtube.com/feeds/api/users/hobbitin5/uploads&num=4',
                            reader: {
                                type: 'json',
                                rootProperty: 'responseData.feed.entries'
                            }
                        }
                            }
 Ext.define('SenchaFirstApp.controller.DistributorsController',{
       extend: 'Ext.app.Controller',
       config: 
       {
           refs: 
           {
               mainlist: '#mainlist',
           },
           control: 
           {
               mainlist: {
                   itemtap: 'dispDetail'
               },
           },

       //when item is tapped
         listeners: {
                itemtap: function(list, index, items, record)
               {
                   console.log('An item was tapped and the listener heard it');
               }
           }
        },
        dispDetail: function(view, record) {
                console.log('Item was tapped on the Data View');
                var oldView = this.getMainlist();       
                var curRecord = oldView.getStore(record);
                var newView = Ext.create('SenchaFirstApp.view.DetailView');
                console.log(curRecord);
                curRecord += 'other stuff';
                newView.setHtml(curRecord);
                newView.add(
        {
         xtype:  'toolbar',
         docked: 'top',
         title: 'Details',
         height: 40,
         items: [
        {
          xtype: 'button',
          text: 'Close',
          width: 100,
          height: 20,   
          name: 'close',
        }]

        }
      )
                oldView.add(newView);
            //  Ext.Viewport.add(newView)
            //  Ext.Viewport.setActiveItem(newView)
        }

       });
Ext.define('SenchaFirstApp.controller.NavController', {
       extend: 'Ext.app.Controller',
       config: 
       {
            refs: 
            {
                 mainlist: 'mainlist',
                 main: '#mainlist',
                closeBtn: 'button[name=close]',
                detaillist: {
                    selector: 'panel panel[name=detail] deetaillist',
                    xtype: 'detailview',
                }
            }, 
            control:
            {
                closeBtn: {
                    tap: 'closeView',
                },

                mainlist: {
                    tap: 'closeView',
                },
                detaillist: {
                    tap: 'closeView',
                }
            }
       },

       closeView: function(){

            var newView = this.getMainlist();
        //  var child = Ext.Viewport.getActiveItem();
            var child = this.getDetaillist();
            var instance = Ext.getCmp('mainlist');
            var activeIndex = instance.indexOf(instance.getActiveItem());
            var curIndex = activeIndex+1;
            var closeView = this.getDetaillist();
            console.log('Close btn clicked' + ' child: ' + this.child +  ' activeIndex: ' + activeIndex);
          // Ext.Viewport.destroy(closeView); //(child);
          newView.remove(child);
          newView.destroy();
          Ext.Viewport.add(Ext.create('SenchaFirstApp.view.DistributorView'));
`          }


})`;
Ext.define('SenchaFirstApp.model.Distributors', {
       extend: 'Ext.data.Model',
       config: {
           idProperty: 'DistrID',
             fields: [
                {name: 'DistrID'},
                {name: 't', type: 'string'},
                {name: 'distr', type: 'string'},
                {name: 'group', type: 'string'},
                {name: 'site', type: 'string'},
                {name: 'status', type: 'string'},
                {name: 'active', type: 'string'},
                {name: 'assigned', type: 'string'},
                {name: 'state', type: 'string'},
                {name: 'schedule', type: 'string'},
                {name: 'finished', type: 'string'},
                //{mapping: 't',
                // name: 'DistrID'}
                ],
       }
       });
var store = Ext.getStore('NodeStore');
            var id = record.get('id');
store.getProxy().setExtraParams({id: id});
            store.load();