Search code examples
extjsextjs3

eXTjS 3.3.1 LiveGrid store.each gives only buffered rows


I use ExtJs 3.3.1 because many extensions don't work under 4.xx One of these extensions is LiveGrid. I can't try but i suppose a simmilar thing happens with a 4.x buffered grid. When i do a report of the lines visible in the grid only the buffered lines are returned, i reposition the current record but the loading of the rest of the records only happens after the reporting finishes. How can i get all the records ?

In an button handler i call toReport(grid).

  toReport = function(grid){
    var store = grid.getStore();
    var view = grid.getView();
    store.each(function(record) {
      Ext.defer(function(){
        index = readRow(store, record);
        if (index % 10 == 0){
          view.focusRow(index);
        }
      }, 500, this);
    });
    console.log(output)
  }

readRow = function(store, record){
  output = "";
  for (var xlCol=1;xlCol<record.fields.length+1;xlCol++){
    var veld = store.fields.itemAt(xlCol-1).name;
    waarde = record.get(veld);
    if (realTypeOf(waarde)==="date"){
      output += waarde.format("d-m-Y");
    }else{
      output += record.get(veld);
    }
  }
  console.log(store.indexOf(record)+ " " + output);
  return store.indexOf(record);
}

Solution

  • I did find a solution by using recursion. Like this the view kan keep up with the enumeration.

      Ext.toExcel = function(grid){
        var store = grid.getStore();
        var view = grid.getView();
        readRow(store, view, 0);
      }
    
      readRow = function(store, view, index){
        output = "";
        record = store.getAt(index);
        for (var xlCol=1;xlCol<record.fields.length+1;xlCol++){
          var veld = store.fields.itemAt(xlCol-1).name;
          waarde = record.get(veld);
          if (realTypeOf(waarde)==="date"){
            output += waarde.format("d-m-Y");
          }else{
            output += record.get(veld);
          }
        }
        //console.log(index+ " " + output);
        if (index % 50 == 0){view.focusRow(index);}
    
        Ext.defer(function(){
          if (index < store.totalLength){
            readRow(store, view, index+1);
          }
        }, 100, this);
      }