adoptRows function not working?

  • 1
  • Problem
  • Updated 8 months ago
  • Solved
  • (Edited)
Not sure what I'm missing TBH.

I have 2 models based on the same object with the same fields. The first model loads on page load. The second model loads on tab loading for first time in tab set.

The second model does get rows but the adoptRows() function isn't doing anything. Tried in snippet and in console.

Tried in console:
skuid.$M('FirstModel').adoptRows(skuid.$M('SecondModel').data)
skuid.$M('FirstModel').adoptRows(skuid.$M('SecondModel').getRows())

According to the documentation, you must provide an array of objects (rows) as the first parameter. Both .data and .getRows() do provide this when I enter them in the console.

It's my understanding that adopting rows from the second model to the first model ignores conditions used to initially query for rows in the first model. I can't imagine that they would be used to "filter" incoming adopted rows. Other than this, I can't make sense of what's going on.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb

Posted 8 months ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
This is on version 10.0.10 and 11.1.7.
Photo of Chandra V

Chandra V, Champion

  • 6,966 Points 5k badge 2x thumb
Not sure this will help, but we have a working adopt situation where users select rows from a table then click an action that adopts the selected rows into another model.  I thought it might help you de-bug your situation.  We don't have the filtering and querying behavior like you, just carrying data from one model to another to then manipulate it.



var params = arguments[0],

    list = params.list,
    selectedItems = params.item ? [params.item] : list.getSelectedItems(),
$ = skuid.$;

SourceModel = skuid.model.getModel('FirstModel');
AdoptModel = skuid.model.getModel('SecondModel');

AdoptModel.abandonAllRows();

$.each( selectedItems,
    function( j, item1 )
    {
        AdoptModel.adoptRows([item1.row]);
    }
);
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
So .... yeah. It was malfunctioning. The row I was trying to adopt was already in the model. :/ Just didn't notice. :D
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
FYI. SOLVED.

User error. ;)
Photo of Mark DeSimone

Mark DeSimone, Official Rep

  • 11,050 Points 10k badge 2x thumb
Thanks for closing the loop Pat. This feels like something that would have tripped me up too - how did you ultimately figure it out?