1. 数据源

//數據源1
var
store = [{id:"001",name:"LiDaWei", age:23},{id:"002",name:"Linimen",age:19}];
//數據源2
var store = Ext.create('Ext.data.Store', {
    fields: ["id","name","age","like"],
    //是否即時加載數據
    autoLoad: false,
    //是否在服务端排序
    remoteSort: true,
    remoteFilter: true,
    //每页显示数据量
    pageSize: 25,
    proxy: {
        type: "ajax",
        url: "xxxx/xxx/x/xx/xas",
        reader: { type: 'json', root: "rows", totalProperty: 'total' },
     extraParams:{id:1}  //参数
  },
  sorters: [{
//排序字段 property: "id", //排序类型,默认为 ASC
    direction: 'desc' }] });
//數據源3
Ext.define('GridStoreModel', {
    extend: 'Ext.data.Model',
    fields: ["id","name","age","like"]
});
var store = Ext.create('Ext.data.Store', {
    model: "GridStoreModel",
    autoLoad: false,
    pageSize: 25,
    proxy: {
        type: "ajax",
        url: "xxxx/xxx/x/xx/xas",
        reader: { type: 'json', root: "rows", totalProperty: 'total' }
    }
});
注意:后面事件用到的是數據源2或3。

3.数据加载前事件

//修改或添加数据加载的参数
store.on("beforeload",function(){ Ext.apply(mainStore.proxy.extraParams, {id:2,name:"ss"}); });
store.addListener('beforeload', function () {   });

4.数据加载后的回调事件

//写法1
store.addListener('load', function () {  alert("Callback");  });
//写法2
store.load({ callback: function (store, options, success) {} });
//写法3
store.on("load",function(){alert("1111");});

 5.添加数据源监听事件

Ext.create('Ext.data.Store', {
    model: "GridStoreModel",
    autoLoad: false,
    pageSize: 25,
    proxy: {
        type: "ajax",
        url: "xxxx/xxx/x/xx/xas",
        reader: { type: 'json', root: "rows", totalProperty: 'total' }
    },
    listeners: {
        beforeload:function(){}
        load: function(){},
     }
});    

 

posted on 2020-06-22 12:26  欲穷  阅读(589)  评论(0编辑  收藏  举报