2013-12-23 56 views
0

我是extjs的新手,我在這裏碰到了。我只是編輯在網絡給出的代碼,但我沒有得到我的網格更新的值動態從json文件中彈出Extjs網格

我的代碼是

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<link rel="stylesheet" type="text/css" 
    href="extjs/resources/css/ext-all.css" /> 
<script type="text/javascript" src="extjs/ext-all.js"></script> 
<script type="text/javascript" src="extjs/ext-all-debug.js"></script> 
<script> 
    Ext.onReady(function() { 
     Ext.define('User', { 
      extend : 'Ext.data.JsonStore', 
      fields : [ { 
       name : 'Date', 
       type : 'string' 
      }, { 
       name : 'TimeStamp', 
       type : 'string' 
      }, { 
       name : 'type', 
       type : 'string' 
      }, { 
       name : 'Class Name', 
       type : 'string' 
      }, { 
       name : 'Method', 
       type : 'string' 
      }, { 
       name : 'Message', 
       type : 'string' 
      } ] 
     }); 

     var user = Ext.create('Ext.data.Store', { 
      storeId : 'user', 
      model : 'User', 
      autoLoad : 'true', 
      proxy : { 
       url : 'C:\Users\753734\Desktop\New folder\LogHandlers\WebContent\Json12.json', 
       reader : { 
        type : 'json' 
       } 
      } 
     }); 
     Ext.create('Ext.grid.Panel', { 
      store : user, 
      id : 'user', 
      title : 'Users', 
      columns : [ { 
       header : 'DATE', 
       dataIndex : 'Date' 
      }, { 
       header : 'TIMESTAMP', 
       dataIndex : 'TimeStamp' 
      }, { 
       header : 'CLASSNAME', 
       dataIndex : 'Class Name' 
      }, { 
       header : 'METHOD', 
       dataIndex : 'Method' 
      }, { 
       header : 'MESSAGE', 
       dataIndex : 'Message' 
      } ], 
      height : 3000, 
      width : 3000, 
      renderTo : Ext.getBody() 
     }); 
     store.load(); 
    }); 
</script> 

的錯誤是

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C) 
Timestamp: Mon, 23 Dec 2013 11:22:30 UTC 


Message: Object expected 
Line: 19450 
Char: 9 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all-debug.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: Object doesn't support this property or method 
Line: 9886 
Char: 17 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all-debug.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 


Message: 'events' is null or not an object 
Line: 21 
Char: 114045 
Code: 0 
URI: file:///C:/Users/753734/Desktop/New%20folder/LogHandlers/WebContent/extjs/ext-all.js 
+0

這是爲什麼標籤java嗎? – Popnoodles

+0

你沒有定義模型! –

+0

如何定義模型!? – sathya

回答

1
Ext.define('User', { 
    extend: 'Ext.data.Model, 
    fields: [ 
     {name: 'Date', type: 'string'}, 
     ... 
    ] 
}) 

var userStore = new Ext.data.JsonStore({ 
    model: 'User', 
    autoLoad: true, 
    proxy: { 
     type: 'ajax', 
     url: 'C:\Users\753734\Desktop\New folder\LogHandlers\WebContent\Json12.json', 
     reader: { 
      type: 'json', 
      root: 'userList', // this is json array name 
      idProperty: 'USER_ID' // you should provide one unique column in JSON, you can hide this column in grid with hidden: true property 
     } 
    } 
}); 

這裏是示例JSON對象。請注意,ctgMains這是root屬性! 還要確保json對象中必須有一個唯一的colum,否則您無法看到網格中的數據是因爲數據衝突!

{"ctgMains":[{"CUST_ASSORT_SECTION_ID":"1","CTG_SECTION":"HORECA"},{"CUST_ASSORT_SECTION_ID":"7","CTG_SECTION":"SCO"},{"CUST_ASSORT_SECTION_ID":"3","CTG_SECTION":"TRADER"}]} 
+0

即使不起作用 – sathya

+0

不可能,請檢查您的json數據! –

+0

m使用extjs 4.2 .... – sathya

0

試圖定義一個模式:

Ext.define('ModelNameHere', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { name: 'date', type: 'string' }, 
     { name: 'timestamp', type: 'string' }, 
     { name: 'type', type: 'string' } 
    ] 
}); 

然後添加屬性來存儲:

model: 'ModelNameHere'