我無法從JsonRest商店填充gridx小部件。查看我的代碼如下: test1.json包含與我在測試庫數據中指定的信息相同的信息。dojo gridx不會讀取JSONRest商店 - 我在這裏失蹤了什麼?
當我將網格更改爲指向測試庫var時,它正確顯示內容,但是當我將它指向reststore變量時,我得到'No items to display'消息。
任何人都知道我錯過了什麼?
var restStore = new dojo.store.JsonRest({target:"http://localhost:9081/MyProj/test1.json"});
var teststore = new Store({
data: [
{id: "1", "description":"First Description"},
{id: "2", "description":"Second Description"},
{id: "3", "description":"Third Description"},
{id: "4", "description":"Fourth Description"}
]
});
grid = new Grid({
cacheClass: Cache,
store: restStore,
structure: [
{id: "description", field: 'description', width: '100%'}
]
});
grid.startup();
您是否嘗試過使用實際服務,或僅使用靜態JSON端點?該端點可能不會像dojo/store/JsonRest期望的那樣設置Content-Range標頭,所以這可能是問題的一部分...請參閱http://dojotoolkit.org/reference-guide/1.9/quickstart/ rest.html獲取更多信息。 –
另請注意,您需要使用'Async'緩存('gridx/core/model/cache/Async')。 – twil
其靜態終點....感謝您的鏈接...有沒有quicj的方式來設置內容範圍標題,所以我可以看到它與靜態json工作?... – blu10