如何使用id在extjs中自动选择网格记录?

时间:2013-03-06 14:51:08

标签: extjs

我想通过在extjs中发送id属性来突出显示特定行来加载网格。我现在不能选择记录。我该怎么做?感谢....

我尝试了一些在代码中注释的代码。你可以在下面看到。

var GrideAktar = function (bilgim) {
    arr = bilgim.split(",");
    bilgi = arr[0];
    secilecek_id = arr[1];

    harita.hide();
    izgaralar.hide();
    chartlar.hide();
    izgara_yp_is_emirleri.hide();


    izgaralar.show();
    izgaralar.setHeight(merkez.getHeight());
    fileStore_yon.loadById(bilgi);
    tree.treeRefresh();

    cuIzgaraKay = null;
    cuAgacNode = bilgi;
    cuAgacSeciliNode = NodeParser(bilgi);
    cuAgacSeciliSehir = SehirParser(bilgi)
    fileGrid_yon.setHeight(merkez.getHeight());
    //fileGrid_yon.getSelectionModel().selectFirstRow();
    //fileGrid_yon.getSelectionModel().valueOf(id);
    //fileGrid_yon.getSelectionModel().selectRow(1);

    //   var idx = fileGrid_yon.getStore().indexOfId(secilek_id);
    //var rowEl = fileGrid_yon.getView().getRow(idx);
    //rowEl.scrollIntoView(fileGrid_yon.getGridEl(),false);
    Ext.select(secilecek_id);
    raporAlanListesiWindow.hide();
    //fileGrid_yon.getSelectionModel().selectRow( this.getStore().indexOfId(id) ); //raporSecenekleriForm.hide(); 
}

3 个答案:

答案 0 :(得分:7)

使用:

grid.getSelectionModel().select(store.getById(id));

store中的id选择grid中的记录。

答案 1 :(得分:1)

这看起来像竞争条件问题。我猜你的代码创建了一个使用ajax或其他东西从远程源加载的网格。尝试将行选择代码嵌入到商店的“load”事件中:

var GrideAktar = function (bilgim) {
    arr = bilgim.split(",");
    bilgi = arr[0];
    secilecek_id = arr[1];

    harita.hide();
    izgaralar.hide();
    chartlar.hide();
    izgara_yp_is_emirleri.hide();


    izgaralar.show();
    izgaralar.setHeight(merkez.getHeight());
    fileStore_yon.on("load", function(){
        fileGrid_yon.getSelectionModel().select(fileStore_yon.getById(id));
    });
    fileStore_yon.loadById(bilgi);
    tree.treeRefresh();

    cuIzgaraKay = null;
    cuAgacNode = bilgi;
    cuAgacSeciliNode = NodeParser(bilgi);
    cuAgacSeciliSehir = SehirParser(bilgi)
    fileGrid_yon.setHeight(merkez.getHeight());
    //fileGrid_yon.getSelectionModel().selectFirstRow();
    //fileGrid_yon.getSelectionModel().valueOf(id);
    //fileGrid_yon.getSelectionModel().selectRow(1);

    //   var idx = fileGrid_yon.getStore().indexOfId(secilek_id);
    //var rowEl = fileGrid_yon.getView().getRow(idx);
    //rowEl.scrollIntoView(fileGrid_yon.getGridEl(),false);
    Ext.select(secilecek_id);
    raporAlanListesiWindow.hide();
    //fileGrid_yon.getSelectionModel().selectRow( this.getStore().indexOfId(id) ); //raporSecenekleriForm.hide(); 
}

答案 2 :(得分:1)

var index = gridPanel.store.find('fieldName', fieldValue);
gridPanel.getSelectionModel().select(gridPanel.store.getAt(index));