zoukankan      html  css  js  c++  java
  • ExtJS用Grid显示数据后如何自动选取第一条记录

      用Grid显示数据后,如何让系统自动选取第一条记录呢?在显示Grid时由于其Store正在loading,没法在Grid选取第一条记录,因为还没有记录,所以应在其Store进行操作。

    查看Ext.data.Store的load()方法如下:

    load( [options] )
    Loads data into the Store via the configured proxy. This uses the Proxy to make an asynchronous call to whatever storage backend the Proxy uses, automatically adding the retrieved instances into the Store and calling an optional callback if required. Example usage:

    store.load({
        scope: this,
        callback: function(records, operation, success) {
            // the operation object
            // contains all of the details of the load operation
            console.log(records);
        }
    });

    以下为重点

    有一个callback函数,可以该回调函数中执行Grid选取第一条记录的操作。
        Store.load({
            callback: function(rec, oper, success){
                if(success){
                    Ext.getCmp('Gridid').getSelectionModel().select(0,true);
                }
            }
        });

     callback: function(rec, oper, success){//回调
                            if(success && rec != undefined && rec != null && rec.length > 0){
                                gridPanel.getSelectionModel().select(0,true);
    解释   gridPanel 当前的 Ext.grid.Panel值   getSelectionModel() 获取model层   select(0,true) 选择第一个参数
                            }
                            // 对象 operation 包含
                            // 所有 load 操作的详细信息
                            // dataList = Ext.JSON.decode(res);
                            // gridStore.loadData(dataList.data, false);
                            // gridPanel.down('pagingtoolbar').bind(gridStore);
                            me.unmask();
                        }

    借鉴:https://blog.csdn.net/wilsonyun/article/details/46632129

  • 相关阅读:
    BZOJ 3670: [Noi2014]动物园 [KMP]
    BZOJ 3569: DZY Loves Chinese II [高斯消元XOR 神题]
    BZOJ 2419: 电阻 [高斯消元 物理]
    BZOJ 2844: albus就是要第一个出场 [高斯消元XOR 线性基]
    BZOJ 4269: 再见Xor [高斯消元 线性基]
    BZOJ 2115: [Wc2011] Xor [高斯消元XOR 线性基 图]
    HDU 3949 XOR [高斯消元XOR 线性基]
    BZOJ 4004: [JLOI2015]装备购买 [高斯消元同余 线性基]
    BZOJ 3105: [cqoi2013]新Nim游戏 [高斯消元XOR 线性基]
    BZOJ 1770: [Usaco2009 Nov]lights 燈 [高斯消元XOR 搜索]
  • 原文地址:https://www.cnblogs.com/mike-mei/p/11133807.html
Copyright © 2011-2022 走看看