日期:2014-05-16  浏览次数:20363 次

GridPanel不显示数据;请大侠们看一下;为什么啊??
GridPanel不显示数据;请大侠们看一下;为什么啊??
var grid = new Ext.grid.GridPanel({
  store: PersonInfoStore ,
  columns: [
  { header: "姓名", dataIndex: 'Name' },
  { header: "职务", dataIndex: 'Zhiwu' },
  { header: "工作单位", dataIndex: 'Gzdw' },
  { header: "办公电话", dataIndex: 'OfficeNumber' },
  { header: "手机", dataIndex: 'TelephoneNumber' },
  { header: "邮箱", dataIndex: 'Email' },
  { header: "备注", dataIndex: 'Remark' }
  ],
  sm: new Ext.grid.RowSelectionModel({ singleSelect: true }),
  autoScroll: true,
  width: 700,
  height: 110,
  frame: true,
  loadMask: true,
  header: false,
  hidden: true,
  layout: "fit",
  renderTo: Ext.getBody(),
  iconCls: 'icon-grid',
  closable: true,
  border: false,
  id: idOfGrid,
  name: idOfGrid,
  stripeRows: true});

var PersonInfoStore = new Ext.data.JsonStore({
  url: "/DzzhXzgltxPersonInfo.mvc/GetAll",
  method: "POST",
  id: "cunjiPersonInfoStore",
  remoteSort: false,
  reader: new Ext.data.JsonReader({
  id: "Name",
  fields: personInfoFields,
  root: "Items",
  totalProperty: "TotalCount"
  })
});

var personInfoFields = [{
  name: 'Name',
  type: 'string'
}, {
  name: 'Zhiwu',
  type: 'string'
}, {
  name: 'Gzdw',
  type: 'string'
}, {
  name: 'OfficeNumber',
  type: 'string'
}, {
  name: 'TelephoneNumber',
  type: 'string'
}, {
  name: 'Email',
  type: 'string'
}, {
  name: 'Remark',
  type: 'string'
}];

后台返回的数据为:但就是不显示啊!!!
{"TotalCount":2,"Items":[{"Name":"1","Zhiwu":"2","Gzdw":"3","OfficeNumber":"4","TelephoneNumber":"5","Email":"6","Remark":"6"},{"Name":"2","Zhiwu":"3","Gzdw":"4","OfficeNumber":"5","TelephoneNumber":"6","Email":"8","Remark":"8"}]}




------解决方案--------------------
是不是把fields定义在了store的后面,store定义在了grid的后面啊?
------解决方案--------------------
有没有执行store.load了?
------解决方案--------------------

var PersonInfoStore = new Ext.data.JsonStore({
url: "/DzzhXzgltxPersonInfo.mvc/GetAll",
method: "POST",
remoteSort: false,
fields: personInfoFields,
root: "Items",
totalProperty: "TotalCount"
});
 
JsonStore 是这样使用的