2012-06-27 70 views
1

我正在開發使用的PhoneGap和煎茶觸摸2安卓2.3.3應用...煎茶觸摸樹商店「對象有沒有方法getRootNode」

我從我重定向到嵌套列表視圖的登入查看我的應用程序......我用了一個在線商店的嵌套列表,而我所定義的類型爲「樹」的店......

的我第一次嘗試加載應用程序,當我點擊登錄它給我一個錯誤...錯誤如下所述:

Uncaught TypeError: Object [object Object] has no method 'getRootNode' at file:///android_asset/www/sencha/sencha-touch-all.js:15 

但獲得如果我強迫錯誤關閉應用程序並打開它再次一切正常......

我的代碼是:

Login.js

Ext.define("DDLApp.view.Login", { 
    //extent panel class 
    extend: "Ext.form.Panel", 
    //DOM in fieldset 
    requires: "Ext.form.FieldSet", 
    xtype: 'formLogin', 
    id:'loginForm', 
    config: { 
     scrollable: 'vertical', 
     id: 'login', 
     items: [ 
      { 
       xtype: "toolbar", 
       docked: "top", 
      }, 
      { 
       xtype: "toolbar", //Toolbar with heading as login 
       docked: "top", 
       title: "Login", 
       ui:'light', 
       id:"idHeaderTwo", 
       cls:"clsLoginHeader"     
      }, 
      { 
       xtype: 'textfield', //textfield for username 
       name: 'Username', 
       required: true, 
       id:"idUserName", 
       cls:"clsUserName", 
       useClearIcon: false 
      }, 
      { 
       xtype: 'passwordfield', //textfield for password 
       name: 'password', 
       required: true, 
       id:"idPassword", 
       cls:"clsPassword", 
       useClearIcon: false 
      }, 
      { 
       xtype: 'button', //Login button 
       text: 'Login', 
       ui: 'confirm', 
       cls:'btnLogin', 
       width:'30%', 
       handler: function(SuccessFlag) { //Login button handler 
        ui: 'confirm', 
        console.log('Login Button pressed'); 
        var form = Ext.getCmp('login'); 

        //get username and password from form elements 
        var user = form.getValues().Username; 
        var pwd = form.getValues().password; 

        var msg = new Ext.MessageBox(); 

        onLoad(); 

        if(user == "" || pwd == "") 
        { 
         var errMsg = ''; 
         if(user == "") 
          { 
           errMsg+= 'Username is required<br/>'; 
          } 
         if(pwd == "") 
          { 
           errMsg+= 'Password is required'; 
          } 
         msg.show({ 
          title: 'LOGIN ERROR', 
          message: errMsg, 
          ui:'light', 
          cls: 'vm_error', 
          showAnimation: 'fadeIn', 
          hideAnimation: 'fadeOut', 
          buttons: [{text:'OK',itemId:'ok'}], 
          fn:function(){ 
           Ext.emptyFn(); 
          } 
         }); 
        }     
        else 
        { 
         form.setMasked({ 
          xtype:'loadmask', 
          message:'Loading...' 
         }); 

         //Check for network connectivity 
         if(onDeviceReady()) 
         { 
         //Fire a json service 
         Ext.util.JSONP.request({ 
          url: DDLApp.app.oneTimeServiceUrl, 
          dataType: "jsonp", 
          params: { 
           type:'fetch', 
           username:user, 
           password:pwd 
          }, 
          success: function (result) { 
           //if username and password matches 
           if(result.Success == true) 
           {             
            //setLocalStorage(result); 
            localStorage.setItem('userName',user); 
            localStorage.setItem('userPassword',pwd); 
            localStorage.setItem('totalData',JSON.stringify(result.Data)); 
            localStorage.setItem('userData',JSON.stringify(result.Data.user)); 
            localStorage.setItem('userIncidentData',JSON.stringify(result.Data.incidentList)); 
            localStorage.setItem('impactData',JSON.stringify(result.Data.impact)); 
            localStorage.setItem('incidentTypeData',JSON.stringify(result.Data.incident_type)); 
            localStorage.setItem('categoryData',JSON.stringify(result.Data.category)); 
            localStorage.setItem('statusData',JSON.stringify(result.Data.statusDropdown)); 

            var indexPanel = Ext.create('DDLApp.view.Main'); 
            Ext.Viewport.add(indexPanel); 
            Ext.Viewport.setActiveItem(indexPanel,{type: 'slide', direction: 'right'}); 
            form.unmask(); 
           } 
           else{ 
            msg.show({ 
             title: 'LOGIN ERROR', 
             message: 'Invalid Username/Password', 
             ui:'light', 
             cls: 'vm_error', 
             showAnimation: 'fadeIn', 
             hideAnimation: 'fadeOut', 
             buttons: [{text:'OK',itemId:'ok'}], 
             fn:function(){ 
              Ext.emptyFn(); 
             } 
            }); 
            form.unmask(); 
           } 
          } 
         }); 
         } 
         ////If network is not present 
         else 
         { 
          form.unmask(); 
          msg.show({ 
           title: 'NETWORK CONNECTION ERROR', 
           message: "We're Sorry but it appears your device is not connected to the internet . Please check your internet settings and try again.", 
           ui:'light', 
           cls: 'vm_error', 
           showAnimation: 'fadeIn', 
           hideAnimation: 'fadeOut', 
           buttons: [{text:'Retry',itemId:'retry'}], 
           fn:function(){ 
            window.location.reload(); 
           } 
          }); 
         } 
        } 
       }, 
      }, 
      { 
       xtype: 'button', //clear button 
       text: 'Clear', 
       width:'30%', 
       ui: 'confirm', 
       cls:'btnClear', 
       style: 'background:#4A4245;', 
       handler: function() { 
        this.up('formpanel').reset(); //reset all form elements 
       }, 
      } 
     ] 
    }, 
}); 

IncidentsList.js

Ext.define("DDLApp.view.IncidentsList", { 
    extend: "Ext.Container", 
    xtype: 'incidentsList', 
    id: 'idIncList', 
    requires:[ 
       'Ext.dataview.NestedList', 
       'Ext.data.proxy.Memory', 
       'Ext.data.TreeStore', 
      ], 
    alias:'widget.incidentslist', 
    config: { 
     id: 'idIncidentList', 
     layout:'fit', 
     items: [ 
       { 
        xtype: "toolbar", 
        docked: "top", 
        cls:'clsDDLHeader', 
        items: [ 
          {xtype:'spacer'}, 
          { xtype: 'title' , 
           cls: 'clsRightTitle', 
           id: 'idIncidentsListTitle', 
           title:"Welcome", 
          }, 
          ] 
       }, 
       { 
        xtype: "toolbar", 
        ui:'light', 
        id:"idHeaderTwo", 
        cls:"clsHeaderTwo" , 
         items: [ 
           { xtype: 'title' , 
            cls: 'clsLeftTitle', 
            title: "My Incidents", 
           }, 
           {xtype:'spacer'} 
           ] 
       }, 
       { 
        xtype: 'nestedlist', 
        id:'idIncidentList', 
        onItemDisclosure:true, 
        cls:'clsNestedIncidentList', 
        toolbar:{id:'idNestedIncidentList'}, 
        loadingText: "Loading Incidents...", 
        emptyText: "<div class=\"empty-text\">No Incidents Found.</div>", 
        getItemTextTpl: function() { 
         var tplConstructor =    
          '<tpl if="TKT_STATUS_NAME == \'CLOSED\'">'+ 
          '<div class="vm_statusRed">'+ 
          '</tpl>'+ 
          '<tpl if="TKT_STATUS_NAME == \'OPENED\'">'+ 
          '<div class="vm_statusYellow">'+ 
          '</tpl>'+ 
          '<tpl if="TKT_STATUS_NAME == \'ASSIGNED\'">'+ 
          '<div class="vm_statusGreen">'+ 
          '</tpl>'+ 
          '<tpl if="TKT_STATUS_NAME == \'PENDING\'">'+ 
          '<div class="vm_statusRed">'+ 
          '</tpl>'+ 
          '<tpl if="TKT_STATUS_NAME == \'RESOLVED\'">'+ 
          '<div class="vm_statusOrange">'+ 
          '</tpl>'+ 
          '<tpl if="TKT_STATUS_NAME == \'REOPEN\'">'+ 
          '<div class="vm_statusYellow">'+ 
          '</tpl>'+ 
          '<div class="vm_dvList"><h4 class="vm_txtName"><span class="vm_listHeader"><label>Inci.#{TKT_ID} by </label><label class="vm_txtFirstName"><i>{FIRST_NAME:ellipsis(15, true)}</i></label></span><div class="date vm_clsDate">{CREATED_ON:date("d-M-y H:i")}</div></h4>'+ 
          '<div class="vm_title">{TKT_SUBJECT}</div>'+ 
          '<div class="vm_subDesc">{TKT_DESC}</div></div></div>'; 
         return tplConstructor; 
        }, 

        store: { 
         type: 'tree', 

         fields: ['TKT_ID', 'CREATED_ON', 'FIRST_NAME', 'TKT_STATUS_NAME', 'TKT_SUBJECT', 'TKT_DESC', 'SEV_DESC', 'SERVICE_NAME', 'CATEGORY_NAME', { 
          name: 'leaf', 
          defaultValue: true 
         }], 

         root: { 
          leaf: false 
         }, 

         data : localStorage.userIncidentData, 

         proxy: { 
          type: 'memory', 
          reader: { 
           type: 'json', 
           rootProperty: 'incidentList' 
          } 
         } 
        }, 

        detailCard: { 
         xtype: "fieldset", 
         scrollable: true, 
         id: "idIncidentDetails", 
         items: [ 
          { 
           xtype: 'textfield', 
           name: 'TKT_SUBJECT', 
           label: 'Subject', 
           labelAlign: 'top', 
           cls:'vm_textFields', 
           clearIcon:false, 
           disabled:true 
          }, 
          { 
           xtype: 'textareafield', 
           name: 'TKT_DESC', 
           label: 'Description', 
           labelAlign: 'top', 
           cls:'vm_textFields', 
           clearIcon:false, 
           disabled:true 
          }, 
          { 
           xtype: 'textfield', 
           name: 'SEV_DESC', 
           label: 'Impact', 
           labelWidth:'45%', 
           cls:'vm_textFields', 
           clearIcon:false, 
           disabled:true 
          }, 
          { 
           xtype: 'textfield', 
           name: 'SERVICE_NAME', 
           id:'displayIncident', 
           cls:'vm_textFields', 
           label: 'IncidentType', 
           labelWidth:'45%', 
           disabled:true 
          }, 
          { 
           xtype: 'textfield', 
           label: 'Category', 
           name: 'CATEGORY_NAME', 
           cls:'vm_textFields', 
           id:'getCategory', 
           labelWidth:'45%', 
           disabled:true 
          }, 
        ], 
        }, 

        listeners: { 
         itemtap: function(nestedList, list, index, element, post) { 
          this.getDetailCard().items.items[0].setHtml(post._data.TKT_SUBJECT); 
          this.getDetailCard().items.items[1].setHtml(post._data.TKT_DESC); 
          this.getDetailCard().items.items[2].setHtml(post._data.SEV_DESC); 
          this.getDetailCard().items.items[3].setHtml(post._data.SERVICE_NAME); 
          this.getDetailCard().items.items[4].setHtml(post._data.CATEGORY_NAME); 
         } 
        } 
       }, 
       {html:'No Incidents Found....',id:'idEmptyText'}], 
    }, 
    initialize: function() { 
     this.callParent(arguments); 
     var incidentStore = Ext.getCmp('idIncidentList').getStore(); 
     Ext.getCmp("idEmptyText").hide(); 
     var getLoginData = localStorage.getItem('userData'); 
     var parseData = JSON.parse(getLoginData); 
     var fname = parseData[0].FIRST_NAME; 
     var getIncidentData = localStorage.getItem('userIncidentData'); 
     var parseIncidentData = JSON.parse(getIncidentData); 
     this.down("#idIncidentsListTitle").setTitle("Welcome, " + fname); 
     if(localStorage.userIncidentData != '[""]') 
      { 
       Ext.getCmp("idEmptyText").hide(); 
       incidentStore.setData(localStorage.userIncidentData).load(); 
      } 
     else 
      { 
       this.down("#inclist").hide(); 
       this.down("#idEmptyText").show(); 
       var msg = new Ext.MessageBox(); 
       msg.show({ 
        title: 'NO INCIDENTS FOUND', 
        message: 'No Incidents have reported by this user', 
        ui:'light', 
        cls: 'vm_error', 
        showAnimation: 'fadeIn', 
        hideAnimation: 'fadeOut', 
        buttons: [{text:'OK',itemId:'ok'}], 
        fn:function(){ 
         Ext.emptyFn(); 
        } 
       }); 
      } 
    }, 
}); 

我需要儘快擺脫這個錯誤...我的應用程序中的一切從第二次開始工作正常...我認爲問題是與我定義的商店...請幫助我的傢伙.. 。 謝謝提前... !!!

+0

所以你的存儲中定義的? –

回答

2

我的店是我IncidentList查看自身聯定義...

store: { 
       type: 'tree', 

       fields: ['TKT_ID', 'CREATED_ON', 'FIRST_NAME', 'TKT_STATUS_NAME', 'TKT_SUBJECT', 'TKT_DESC', 'SEV_DESC', 'SERVICE_NAME', 'CATEGORY_NAME', { 
        name: 'leaf', 
        defaultValue: true 
       }], 

       root: { 
        leaf: false 
       }, 

       data : localStorage.userIncidentData, 

       proxy: { 
        type: 'memory', 
        reader: { 
         type: 'json', 
         rootProperty: 'incidentList' 
        } 
       } 
      }, 
0

這是真的:對象的翻譯:有沒有方法getRootNode 這種方法不再ST2可用,看看在API docs

其實,這是ST代碼的唯一的地方有這種方法離開。嘗試在TreeStore

removeAll: function() { 
     this.getRootNode().removeAll(true); 
     this.callParent(arguments); 
}, 

編輯煎茶代碼

removeAll: function() { 
     this.getRoot().removeAll(true); 
     this.callParent(arguments); 
    },