+ -
当前位置:首页 → 问答吧 → ExtJs4.0 grid store用 ajax 请求数据能显示不能分页了 看代码

ExtJs4.0 grid store用 ajax 请求数据能显示不能分页了 看代码

时间:2011-06-20

来源:互联网

/// <reference path="vswd-ext_2.0.2.js" />
/**************************************/
Ext.Loader.setConfig({ enabled: true });

Ext.Loader.setPath('Ext.ux', '../extjs/ux');

Ext.require([
  'Ext.data.*',
  'Ext.grid.*',
  'Ext.util.*',
  'Ext.ux.data.PagingMemoryProxy',
  'Ext.ux.ProgressBarPager'
]);
/**************************************/
Ext.onReady(function () {
  /*********************************/

  var myData = [['1', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['15', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['16', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['17', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['18', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['19', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['20', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['21', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['22', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['23', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['24', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['25', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['26', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],
  ['27', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00']];

  Ext.define('Company', {
  extend: 'Ext.data.Model',
  idProperty: 'company',
  fields: [
  { name: 'NoteId' },
  { name: 'NoteTitle'},
  { name: 'NoteContent' },
  { name: 'CreateTime'}
  ]
  });
  var store = Ext.create('Ext.data.Store', {
  model: 'Company',
  remoteSort: true,
  pageSize: 10,
  proxy: {
  type: 'ajax',
  url: '../ExtData/Mymemo.ashx?oper=list',
  reader: {
  type: 'array'
  }
  }
  // 这样就可以显示和分页 ajax 就不行了 
// proxy: {
// type: 'pagingmemory',
// data: myData,
// reader: {
// type: 'array'
// }
// }
  });

  /*********/


  var grid = Ext.create('Ext.grid.Panel', {
  title: '我的便签列表',
  dockedItems: [{
  xtype: 'toolbar',
  items: [{
  iconCls: 'icon-add',
  text: '添加便签',
  scope: this,
  handler: function () {
  Ext.MessageBox.alert('d', 'c');
  }
  }]
  }],
  store: store,
  collapsible: true, //是否折叠
  columns: [{
  id: 'company',
  text: '编号',
  sortable: true,
  dataIndex: 'NoteId',
  width: 75
  //flex: 1
  }, {
  text: '标题',
  sortable: true,
  dataIndex: 'NoteTitle',
  width: 100
  }, {
  text: '内容',
  sortable: true,
  // renderer: change, //可以处理穿来的数据 函数名称
  dataIndex: 'NoteContent',
  width: 200
  }, {
  text: '时间',
  sortable: true,
  // renderer: pctChange,
  dataIndex: 'CreateTime',
  width: 150
  }],
  stripeRows: true,
  height: 420,
  width: '100%',
  frame: true,
  bbar: Ext.create('Ext.PagingToolbar', {
  pageSize: 10,
  store: store,
  displayInfo: true,
  plugins: Ext.create('Ext.ux.ProgressBarPager', {})
  })
  });

  grid.render('Grid_div');

  store.load();
  /********************************************/

});




不太明白是为什么 请各位帮忙解决下  
下面是页面返回的数据

[['1', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['15', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['16', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['17', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['18', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['19', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['20', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['21', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['22', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['23', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['24', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['25', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['26', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00'],['27', '试试', '嗯 这就是一个记事本 呵呵 挺好的', '2011-6-15 0:00:00']]


作者: yang296264808   发布时间: 2011-06-20

帮顶 避免杯具

作者: inetfuture   发布时间: 2011-06-21