Get help with testing, discuss unit testing strategies etc.


Post by jflowers45 »

A little while back, Nikolay provided a patch to make the t.getRow() method work with buffered grids and it's great.
viewtopic.php?f=20&t=9171

I have one question. About 1 in 10 times when I call this method on my buffered, grouped grid it fails. I'm calling it like this:
{ waitForRowsVisible: 'demandWRmatrix', desc: "Wait for Demand Matrix Rows"},
function (next) {
  var g = t.cq1('demandWRmatrix');
  var rec = g.getStore().findRecord('STATUS', 'Validated');
  var rowIndex = g.getStore().indexOf(rec);
  var t2 = t;
  g.ensureVisible(rowIndex, { 
    animate:true, 
    select:true,
    callback:function() { 
      g.getView().focusRow(rec);
      var cell_edit = t2.getCell(g, rowIndex, 0); //cell_edit sporadically returns null
Here's the relevant portion of the patch Nikolay provided. Note the call to grid.getView().getNode(record)
if (grid.getView().bufferedRenderer) {
                    var record  = grid.getStore().getRange(index, index + 1)[ 0 ]

                    if (record) {
                        domNode = grid.getView().getNode(record)
                    }
On the rare occasions where getCell fails, the value of record comes back defined, but grid.getView.getNode(record) returns null. I then dumped the contents of grid.getView().getNodes() and noticed then in the cases where my test fails, getNodes() is only returning the grouped headers, whereas when it works fine, getNodes() contains the actual row records.

Does this report make sense? Is there an intelligent way to wait to make sure that grid.getView().getNodes returns the rows and not the grouped headers?

Post by nickolay »

Hm.. So you are saying, in the "ensureVisible" callback, only header rows are rendered? This sounds like an Ext bug. Anyway, perhaps additional "waitFor" should be added, awaiting for regular row in the dom, something like:
g.ensureVisible(rowIndex, {
    animate:true,
    select:true,
    callback:function() {
        // sporadically only header rows are rendered
        t.waitForSelector('NON_HEADER_ROW_SELECTOR', g.getView().getEl(), function () {
            g.getView().focusRow(rec);
            var cell_edit = t2.getCell(g, rowIndex, 0); //cell_edit sporadically returns null
        })

Post by jflowers45 »

that sounds like a great idea. thanks!

Post Reply