1
我正在將extJS與Grails集成。將ExtJS與Grails集成時沒有輸出
下面是我的music.TuneController中的列表動作。
def list = {
def tuneInstanceList = new ArrayList<Tune>()
def tune= new Tune();
tune.playerId = "ASDF";
tune.playerPrice= "100";
tuneInstanceList.add(tune);
def listResult = [ total: tuneInstanceList.size(), items: tuneInstanceList]
render listResult as JSON
}
我在調grid.js代碼
/*
* Ext JS Library 2.0 Beta 1
* Copyright(c) 2006-2007, Ext JS, LLC.
* [email protected]
*
* http://extjs.com/license
*/
Ext.onReady(function(){
// create the Data Store
var ds = new Ext.data.Store({
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: 'http://localhost:8080/music'}),
reader: new Ext.data.JsonReader({
results: 'total',
root:'items',
id:'id'
},
[
{name: 'playerId' },
{name: 'playerPrice'}
]
)
});
var cm = new Ext.grid.ColumnModel([
{header: "Player Id", width: 120, dataIndex: playerId },
{header: "Player Price", width: 180, dataIndex: 'playerPrice'}
]);
cm.defaultSortable = true;
// create the grid
var grid = new Ext.grid.GridPanel({
ds: ds,
cm: cm,
renderTo:'grid-example',
width:540,
height:200
});
});
的list.gsp:
<%@ page import="music.Tune"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="layout" content="test" />
<g:set var="entityName" value="${message(code: 'song.label', default: 'Song')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
<g:javascript library="tune-grid"/>
</head>
<body>
<div class="body">
<!--<g:javascript library="examples"/>-->
<!-- EXAMPLES -->
<div id="grid-example"></div>
</div>
</body>
</html>
當動作被調用時,我得到了下面的輸出。看起來控制器根本不會到達list.gsp。
{"total":1,"items":[{"class":"music.Tune","playerId":"ASDF", playerPrice":"100","playerDep":null}]}
你能告訴我我在做什麼錯嗎?
謝謝!
修正了....我傻....編輯QN太... ... Bt仍然在同一個地方......想法? – MAlex 2010-10-15 07:12:33
更新了我的答案... – leebutts 2010-10-15 07:15:40
Amazin ....這工作李....非常感謝幫助 – MAlex 2010-10-15 07:57:45