wangwenbincn 2013-05-07 09:19
浏览 201
已采纳

SSH+EXTJS前台不能显示数据?

我是一个新手,最近碰到一个小问题,望有识之士能给与我解答!非常感谢!
一个简单的问题,后台得到的数据通过前台显示,使用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不是很熟,望大侠不以此问题低劣,不吝赐教!

  • 写回答

3条回答 默认 最新

  • iteye_20778 2013-05-08 10:27
    关注

    会不会是json最后少了一个 } ?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率