0
Ext.application({
  launch: function () {

    Ext.define("User", {
      extend: "Ext.data.Model",
      config: {
        fields: [{name: "title", type: "string"}]
      }
    });

    var myStore = Ext.create("Ext.data.Store", {
      model: "User",
      proxy: {
        type: "ajax",
        url : "http://www.imdb.com/xml/find?json=1&nr=1&tt=on&q=twilight",
        reader: {
          type: "json",
          rootProperty: "title_popular"
        }
      },
      autoLoad: true
    });

    var view = Ext.Viewport.add({
      xtype: 'navigationview',
      //we only give it one item by default, which will be the only item in the 'stack' when it loads
      items: [{
        xtype:'formpanel',
        title: 'SEARCH IMDB MOVIES ',
        padding: 10,
        items: [{
          xtype: 'fieldset',
          title: 'Search Movies from IMDB',
          items: [{
            xtype: 'textfield',
            name : 'Movie Search',
            label: 'Search Movie'
          }, {
            xtype: 'button',
            text: 'Submit',
            handler: function () {
              view.push({
                //this one also has a title
                title: 'List of Movies',
                padding: 10,
                //once again, this view has one button
                items: [{
                  xyz.show();
                }]
              });
            }
          }]
        }]
      }]
    });

    var xyz = new Ext.create("Ext.List", {
      fullscreen: true,
      store: myStore,
      itemTpl: "{title}"
    });
  }
});

错误在于 xyz.show(); 如果我删除 xyz.show() ,它将正常工作;但我想在单击按钮后显示列表
这是单击按钮时的导航视图我想显示列表

4

2 回答 2

0

试试这个 :

handler: function () {
  view.push({
    //this one also has a title
    title: 'List of Movies',
    padding: 10,
    //once again, this view has one button
    items: [
      xyz
    ]
  });
}
于 2013-03-06T16:23:46.007 回答
0

如下更改您的 xyz 列表:

var xyz = new Ext.create("Ext.List", {
  //this one also has a title
  title: 'List of Movies',
  padding: 10,
  xtype:'xyz',
  alias:'xyz',
  hidden:true,
  fullscreen: true,
  store: myStore,
  itemTpl: "{title}"
});

然后在它下面写

view.add(xyz);

然后在你的处理程序中

handler: function () {
    xyz.show();
}

未经测试,但它应该可以进行调整。

于 2013-03-06T20:27:01.770 回答