我是一个新手,最近碰到一个小问题,望有识之士能给与我解答!非常感谢!
一个简单的问题,后台得到的数据通过前台显示,使用extjs4.其中extjs的代码如下:[code="java"]
Ext.Loader.setConfig({enabled: true});
Ext.Loader.setPath('Ext.ux', 'extjs/examples/ux/');
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.tip.QuickTipManager',
'Ext.ux.LiveSearchGridPanel'
]);
Ext.onReady(function() {
Ext.QuickTips.init();
// sample static data for the store
Ext.define('City', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string'},
{ name: 'countryCode',type: 'string'},
{ name: 'district', type: 'string'},
{ name: 'population', type: 'int' }
]
});
function population(val) {
if (val > 50000) {
return '<span style="color:green;">' + val + '</span>';
} else if (val < 50000) {
return '<span style="color:red;">' + val + '</span>';
}
return val;
}
var store = Ext.create('Ext.data.Store', {
storeId:'cityStore',
model: "City",
proxy: {
type: 'ajax',
url: 'city!list.action',
reader: {
type: 'json',
root: 'citys'
}
},
autoLoad : true
});
// create the Grid, see Ext.
Ext.create('Ext.grid.Panel', {
title: 'City',
store: Ext.data.StoreManager.lookup('cityStore'),
columns: [
{header: 'ID', dataIndex: 'id'},
{header: 'Name', dataIndex: 'name', editor: 'textfield'},
{header: 'countryCode', dataIndex: 'countryCode', flex:1,
editor: {
xtype: 'textfield',
allowBlank: false
}
},
{header: 'district', dataIndex: 'district'},
{header: 'population', dataIndex: 'population', renderer:population}
],
selType: 'rowmodel',
plugins: [
Ext.create('Ext.grid.plugin.RowEditing', {
clicksToEdit: 1
})
],
height: 200,
width: 400,
renderTo: Ext.getBody()
});
});[/code]
后台的SQL语句是运行了的,但是前台就是显示不出来,请问这是怎么回事呢?本人对JS不是很熟,望大侠不以此问题低劣,不吝赐教!