java_天照 2013-12-25 07:22 采纳率: 33.3%
浏览 4234
已采纳

SpringMVC+hibernate4+Extjs4.2+mysql


  1. 后台处理数据库数据(读取数据)
    @RequestMapping("/getmanagers") @ResponseBody public Map getWorkOrders(String page,String limit,String start,String all){ int pageInt = Integer.parseInt(page); int limitInt = Integer.parseInt(limit); int startInt = Integer.parseInt(start); Map map = new HashMap(); List list = workOrdersService.getWorkOrders(); List listTemp ; //数据库中的结果条数小于分页限制,则直接返回结果 map.put("total",list.size()); if(list.size()<=limitInt){ map.put("workOrders", list); return map; } if(all!=null){ map.put("workOrders", list); return map; } //截取List if(pageInt*limitInt>=list.size()){ listTemp = list.subList(startInt, list.size()); }else{ listTemp = list.subList(startInt, pageInt*limitInt); } map.put("workOrders", listTemp); return map; }

  1. ExtMVC

中的model
Ext.define('tw.model.GlobalStatisticsModel',{
extend : 'Ext.data.Model',
fields: [
{name: 'id', type: 'int',sortType :'aesc'},
{name: 'failuretime',type: 'date'},
{name: 'failureaddress', type: 'string'},
{name: 'repairtime', type: 'string'},
{name: 'maintenanceman', type: 'string'},
{name: 'completion', type: 'string'},
{name: 'failurecontent', type: 'string'}
]
});
中的store
Ext.define('tw.store.GlobalStatisticsStore',{
extend:'Ext.data.Store',
model:'tw.model.GlobalStatisticsModel',
pageSize: 17,
proxy:{
type:'ajax',
url: 'gdgl/getmanagers',
reader: {
type: 'json',
root: 'workOrders'
},
writer:{
type: 'json'
}
},
autoLoad: true
});
然后是Ext的View
Ext.define('tw.view.gdgl.GlobalStatisticsView',{
extend : 'Ext.grid.Panel',
xtype : 'globalStatisticsView',
store:'GlobalStatisticsStore',
selType : 'checkboxmodel',
forceFit:false,
columns: [{
text: 'ID',
dataIndex: 'id',
width:50,
editor: {
readOnly:true
}
}, {
// text: '故障时间',
header:'故障时间',
dataIndex: 'failuretime',
width:180,
renderer : Ext.util.Format.dateRenderer('Y-m-d H:i:s'),
editor: {
allowBlank: false
}
}, {
text: '故障地点',
dataIndex: 'failureaddress',
width:200,
editor: {
allowBlank: false
}

  • 写回答

3条回答 默认 最新

  • java_天照 2013-12-30 07:00
    关注

    这个我有答案了,java取出来的字符串是一个13位的时间戳,放到Extjs里的话必须要转换为时间才能显示,要不就会显示为13位的时间戳。Ext的view可以改为
    Ext.define('tw.view.gdgl.GlobalStatisticsView',{
    extend : 'Ext.grid.Panel',
    xtype : 'globalStatisticsView',
    store:'GlobalStatisticsStore',
    selType : 'checkboxmodel',
    forceFit:false,
    columns: [{
    text: 'ID',
    dataIndex: 'id',
    width:50,
    editor: {
    readOnly:true
    }
    }, {
    // text: '故障时间',
    header:'故障时间',
    dataIndex: 'failuretime',
    width:180,
    renderer:function(value){
    return new Date(parseInt(value)).toLocaleString();//自动转化为时间
    }
    }, {
    text: '故障地点',
    dataIndex: 'failureaddress',
    width:200,
    editor: {
    allowBlank: false
    }

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

报告相同问题?

悬赏问题

  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来