反应表显示两个键之一

时间:2014-12-04 13:46:13

标签: meteor

我正在使用aslagle:reactive-table

文件:https://github.com/ecohealthalliance/reactive-table

{{> reactiveTable collection=payments settings=reactiveTableSettingsPayments}}

我的设置是

reactiveTableSettingsPayments: function(){
        return {
            rowsPerPage: 10,
            showNavigationRowsPerPage: false,
            fields: [
            {
                key: 'new_id', 
                label: 'Payment Id',
                fn: function(value,object){
                    if(!value){
                        //here I want old_id if new_id didn't exist
                    }
                }
            },
            {
                key: 'buyer_name', 
                label: 'Buyer',
            } 
}

对于密钥new_id,如果该密钥在我想要显示的集合中不存在old_id

怎么做?

1 个答案:

答案 0 :(得分:1)

reactiveTableSettingsPayments: function(){
        return {
            rowsPerPage: 10,
            showNavigationRowsPerPage: false,
            fields: [
            {
                key: 'new_id', 
                label: 'Payment Id',
                fn: function(value,object){
                    if(!value){
                       return object.old_id;
                    }
                    else{
                       return falue;
                    }
                }
            },
            {
                key: 'buyer_name', 
                label: 'Buyer',
            } 
}