2013-01-09 34 views
2

T使用ExtJS4.0.1,MVC架構編寫代碼。當我開發主表單時,我遇到了搜索擴展的問題。ExtJS控制器probelem。 Uncaught TypeError:Object [object Object] has no method'setSortState'

當我試圖在控制器中創建新的小部件時,我需要在子面板中呈現結果。所以當我寫的代碼示例我遇到以下問題:

**Uncaught TypeError: Object [object Object] has no method 'setSortState'** 

我不明白爲什麼它給出的錯誤信息。我需要一些幫助來解決這個問題。

下面我想告訴我的代碼:

//Panel which is showing to user 

    Ext.define('Semantics.view.main.menuView', { 
     extend: 'Ext.panel.Panel', 
     layout: 'fit', 
     alias: 'widget.Menu', 
     title: "", 
     tbar: [ 
      { 
//search field 
         name:'mainSearchText', 
         id:'mainSearchText', 
         xtype: 'textfield', 
         defaultValue: 'Search', 
         height: 20 
      }, 
      { 
       name:'mainSearchButton', 
       id:'mainSearchButton', 
       xtype: 'button', 
       text: 'Find', 
       height: 20 
      } 
     ] 
    }); 


//controller for search request 
    Ext.define('Semantics.controller.main.mainController', { 
     extend: 'Ext.app.Controller', 
     views: ['main.menuView','mainSearch.MainSearchResultForm'], 
     refs: [ 
      { ref: 'menuPanel', selector: 'Menu' }, 
      { ref:'mainSearchText',selector:'#mainSearchText'}, 
      {ref: 'mainSearchForm',selector:'#mainSearchForm'}, 
      {ref:'MainSearchGrid',selector:'#MainSearchGrid'} 
     ], 

     init: function() { 
      this.control({ 
       'Menu': { 
        render: this.onPanelRendered 
       }, 
       'Menu button[name="mainSearchButton"]': { 
        click: this.onButtonClick 
       } 
      }); 
     }, 
     onButtonClick: function (button) { 
      var me = this; 
      if(button.name=="mainSearchButton") { 

         var mtextFiled = me.getMainSearchText().getValue(); 

         console.log(mtextFiled); 
         Ext.Ajax.request({ 
          scope: this, 
          url: 'app/mainSearchT/findText/', 
          method: 'POST', 
          params: { 
           text: me.getMainSearchText().getValue() 
          }, 
          success: function (result) { 
           mainPanel = me.getMenuPanel(); 
           mainPanel.removeAll(true); 
           loadingMask = new Ext.LoadMask(mainPanel, { msg: "Loading" }); 
           loadingMask.show(); 
           var mname = 'MainSearchResultForm'; 
           var start_info_panel = Ext.widget(mname); 
           mainPanel.items.add(start_info_panel); 
           loadingMask.hide(); 
           mainPanel.doLayout(); //that line gives that error 
          }, 
          failure: function (result) { 
           console.log(result); 
          } 
         }); 

      } 
     }, 

     onPanelRendered: function() { 
     } 
    }); 
+0

看起來像問題是在你調用setSortState方法時#MainSearchGrid –

+0

我不能重現你的問題......但是嘗試重命名小部件'Menu'到'MyMenu',因爲在ExtJS中已經有一個xtype'Menu '!如果您正在使用MVC結構,請檢查所有文件名是否與您的Ext.define名稱匹配! – harry

回答

4

我遇到了同樣的錯誤,當我列入Ext.grid.Panel列不受支持的xtype。我必須刪除解決問題的xtype。

相關問題