icefruit 2012-12-14 01:27 采纳率: 0%
浏览 226
已采纳

完整EXTJS一段代码,我这里GRID死活不显示数据。哪位朋友帮忙看看。

[code="java"]

Ext.onReady(function() {

Ext.ns('app.grid');
var xg = Ext.grid;
var detailViewReader = new Ext.data.JsonReader({
idProperty: 'autoid',
root : 'items',
totalProperty: "results",
fields: [
{name: 'autoid', type: 'int',mapping:'autoid'},
{name: 'usePlanAutoId', type: 'int',mapping:'usePlanAutoId'},
{name: 'itemName', type: 'string',mapping:'itemName'},

{name: 'itemMoney', type: 'float',mapping:'itemMoney'},
{name: 'remark', type: 'string',mapping:'remark'}
]
});

var detailViewStore = new Ext.data.JsonStore({
autoLoad: true,

reader: detailViewReader,
//url : _path +"servlet/UsePlanDetailServlet?sign=json",
url : "test.json",
method : 'POST',
sortInfo: {field: 'autoid', direction: 'ASC'},
params:{
"capitalUsePlanAutoId" : ""
}
});
var pagingtoolbar = new Ext.PagingToolbar({
pageSize:_pageSize,
store:detailViewStore,
displayInfo:true,
displayMsg: '从{0}至{1},共{2}条记录',
emptyMsg:"No records to display"
});
var detailViewGrid = new xg.GridPanel({
store: detailViewStore,
columns: [
new Ext.grid.RowNumberer(),
{
header: '内码',
dataIndex: 'autoid',
width: 40,
sortable: true
},{
header: 'usePlanAutoId',
dataIndex: 'usePlanAutoId',
width: 40,
sortable: true,
hidden : true
},{
header: '项目名称',
dataIndex: 'itemName',
width: 150,
sortable: true
},{
xtype: 'numbercolumn',
header: '金额',
dataIndex: 'itemMoney',
format: '$0,0.00',
width: 100
},{
header: '备注',
dataIndex: 'remark',
align: 'center',
width: 150
}
],
id: "usePlanDetailViewGrid",
//totalProperty:"results",
//frame: true,
width: 800,
height: 450,
//region : "center",
//clicksToEdit: 1,
collapsible: false,
//animCollapse: false,
//trackMouseOver: false,
bbar : pagingtoolbar,
//enableColumnMove: false,

iconCls: 'icon-grid'
});

var CapitalUsePlanDetail = new Ext.Panel(

{
id : "UsePlanDetailOperationWin",
title : "明细",
iconCls : "btn-operation",
width : 600,
height : 500,
closeAction: 'hide',
region : 'center',
items : [
detailViewGrid
]

});

new Ext.Viewport( {
layout : 'border',
title : 'tttt',
items : [ CapitalUsePlanDetail ],
renderTo : Ext.getBody()
})

});
[/code]

  • 写回答

1条回答 默认 最新

  • FangXingXing007 2012-12-14 09:05
    关注

    是ExtJS4吗?
    用这种简单的方式定义store
    先把PageToolBar去掉,看能不能正常显示
    var mycolumns = []
    //可以用ExtJS自动生成的序号,或是自己获取的ID号
    mycolumns.push(Ext.create('Ext.grid.RowNumberer'));// 添加行号列,不需要导入外部插件
    mycolumns.push( {
    header : 'ID',
    dataIndex : 'id',
    flex : 2
    });
    mycolumns.push( {
    header : '书号',
    dataIndex : "code",
    flex : 2
    });
    mycolumns.push( {
    header : '书名',
    dataIndex : "name",
    flex : 2
    });
    mycolumns.push( {
    header : '价格',
    dataIndex : "price",
    flex : 2
    });
    var bookData = Ext.create('Ext.data.Store', {
    fields : ["id", "code","name","price"],
    autoLoad : true,
    proxy : {
    type : 'ajax',
    //通过web请求获取格式如下的数据,返回是这种格式的字符串就可以
    /*
    [{"name":"name","price":"12","code":"SBN-1111"},
    {"name":"name","price":"12","code":"SBN-1111"},
    {"name":"name","price":"12","code":"SBN-1111"}]
    */
    url : './getBookData',
    reader : {
    type : 'json'
    }
    }
    });
    var grid = Ext.create('Ext.grid.Panel', {
    layout : 'anchor',
    disableSelection : true,
    title : '书籍信息',
    columns : mycolumns,
    renderTo : Ext.get('reportgrid'),
    store : bookData,
    width : Ext.getBody().getWidth(),
    height : Ext.getBody().getHeight()
    });
    });

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 为什么我写出来的绘图程序是这样的,有没有lao哥改一下
  • ¥15 js,页面2返回页面1时定位进入的设备
  • ¥50 导入文件到网吧的电脑并且在重启之后不会被恢复
  • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
  • ¥15 绘制多分类任务的roc曲线时只画出了一类的roc,其它的auc显示为nan
  • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败