adoptRow doAppend option not working

  • 1
  • Problem
  • Updated 3 years ago
I'm using the adoptRows method to successfully add rows from another model of the same object type. The problem is that the rows are being prepended, and I'd like them appended instead.

When calling the method:


model.adoptRow(row, {doAppend: true});


The doAppend option doesn't change anything and the row is still prepended. Any advice would be appreciated, thanks!

Eulogio
Photo of Eulogio Gallo

Eulogio Gallo

  • 1,874 Points 1k badge 2x thumb
  • confused

Posted 3 years ago

  • 1
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Hi Eulogio,

Your syntax looks correct, so I'm not sure what's going on. What version of Skuid are you running?
Photo of Eulogio Gallo

Eulogio Gallo

  • 1,874 Points 1k badge 2x thumb
I'm using 7.27.1. And yeah the documentation says this is correct, so I'm not sure what the issue is.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
Can you paste the relevant portion of the code. Maybe the entire snippet if it's not too long?
Photo of Eulogio Gallo

Eulogio Gallo

  • 1,874 Points 1k badge 2x thumb
Sure! What I'm doing is moving rows from one model to another, and then adding a final row that has aggregated info:


$.each(allModels, function() {
var rowCopies = this.getRows();
rowCopies[0].Bucket = this.id;

// row is prepended here
bucketModel.adoptRows(rowCopies);
});

var row = bucketModel.createRow();

row.Bucket = 'TOTAL';
row.countId = countTotal;
row.sumTBAAggregateCharterc = charterTotal;
row.sumTBAAggregateDistrictc = districtTotal;
row.sumTBAAggregatePrivatec = privateTotal;
row.sumTBAAggregateMalec = maleTotal;
row.sumTBAAggregateFemalec = femaleTotal;
row.sumTBAAggregateAfricanAme = afroTotal;
row.sumTBAAggregateAsianAmeri = asianTotal;
row.sumTBAAggregateHispanicc = hispanicTotal;
row.sumTBAAggregateWhitec = whiteTotal;

// should be appended here
bucketModel.adoptRow(row, { doAppend: true });

// updating rows to refresh table visual
var allRows = bucketModel.getRows();
bucketModel.updateRows(allRows);


And as you can see below, the row is still prepended on this table, regardless of what I set the flag.
Photo of Ben Hubbard

Ben Hubbard, Employee

  • 12,490 Points 10k badge 2x thumb
I think the problem is that your creating the row with createRow first, and then calling adoptRow. Adopt row will only adjust the position of a row if it's not already in the model. Try using the doAppend option on your create row api call.