Get current row key in reactive table and use it

I have this settings that creates my reactive table

settings: function () {
    return {
    collection: 'examsettings',
    rowsPerPage: 5,
    showFilter: true,
    showNavigation: 'auto',
    fields: [
        { key: '_id', label: 'Id' },
        { key: 'examschoolid', label: 'School Id' },
        { key: 'examname', label: 'Exam Name' },
        { key: 'examay', label: 'Exam Academic Year' },
        { key: 'examterm', label: 'Exam Term' },
        { key: 'examclass', label: 'Exam Class' },
        { key: 'examdate', label: 'Exam Date' }
    ],
    useFontAwesome: true,
    group: 'client'
};
},

Is it possible to access current row data when creating a dynamic column,for instance

{
key: 'enames', 
label: 'Exam Term Names ',
fn: function(t){
var t = this;
var tn = t.examterm;
var cursor = Terms.findOne(tn);
return cursor.map(function(doc) {
return doc.termnames;
});   
}
},

Yes. The full signature for the fn function is:

fn: function (value, object, key) { }

Ok,this does not get the termnames

 fn: function(value,object,key){
                    var tn = object.examterm;
                var cursor = Terms.findOne(object.examterm);
        return cursor.map(function(doc) {
            return doc.termnames;
        });   
                }

although this gives the data i want var tn = object.examterm;

Edit

var cursor = Terms.find(object.examterm); seems to be working.

No, the object is the row, key is the column property name, and value the column property value.

1 Like

Many thanks. Everything works now.