Question

Get data from active row of detail

Hi,

I'm just wondering how I would get data from the active row of a detail synchronously.

I am in the detail schema and I know we are able to get the active row by 

var activeRow = this.get("ActiveRow");

but how would I go about getting a lookup that is shown in the columns on a page from this active row?

Thanks,

Like 0

Like

2 comments

this.get("ActiveRow") return id, try this to get data from row

const activeRecordId = this.get("ActiveRow");
const gridData = this.getGridData();
const value = gridData.get(activeRecordId).values;
console.log("Active Record: ", {value});

Tyler,

In addition to what Romodan shared:

// get the current row entity (not just the Id)
var item = this.getActiveRow();
var colValue = item.get("UsrSomeColumn");

Which does the same as this:

var currentId = this.get("ActiveRow");
var data = this.getGridData();
var item = gridData.get(currentId);
var colValue = item.get("UsrSomeColumn");

Note, for either of these approaches, only the columns displayed in the detail will be available since they are the only columns added to the ESQ populating the detail. If you want other columns available, that might not be displayed in the detail, you can add those to the ESQ by overriding the initQueryColumns, like this:

initQueryColumns: function(esq) {
    this.callParent(arguments);
 
    if (!esq.columns.contains("UsrSomeOtherColumn")) {
        esq.addColumn("UsrSomeOtherColumn");
    }
}

Ryan

Show all comments