Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs 如何在使用checkboxmodel加载网格时默认设置选定行_Extjs_Extjs4_Extjs4.1 - Fatal编程技术网

Extjs 如何在使用checkboxmodel加载网格时默认设置选定行

Extjs 如何在使用checkboxmodel加载网格时默认设置选定行,extjs,extjs4,extjs4.1,Extjs,Extjs4,Extjs4.1,详情如下: 提前感谢 欢迎提供更好的解决方案 grid.getStore().load({ scope:this, callback: function (records, operation, success) { if(success){ /*var store = grid.getStore(); var records = []; store.queryBy(function(record,id){

详情如下:


提前感谢

欢迎提供更好的解决方案

grid.getStore().load({

scope:this,

callback: function (records, operation, success) {
    if(success){

        /*var store = grid.getStore();
        var records = [];
        store.queryBy(function(record,id){

            if(record.data.chkd){
                    records.push(record);
                }

            console.log(id);

        },this);

        grid.getSelectionModel().select(records,false,false);
        */
          var sm = grid.getSelectionModel();
          Ext.each(records, function(record) {
              if(record.data.chkd){
                var row = record.index;
                sm.select(row, true);
              }
      });



    }else{

        //alert(success);
        //console.log(operation.exception);
    }
}}
);

在Ext JS 4.2.1中运行的测试代码:

grid.on('viewready', function(){
    grid.selModel.doSelect(grid.store.data.items[0]);
});

请同时添加问题的内容,以防将来链接失效。我建议在viewready函数中这样做。这正是他们在文档中建议的:当网格视图可用时,viewready(这是eOpts)将触发(使用此选项选择默认行)。