Problem with mData and access fields in datatables

Problem with mData and access fields in datatables

cybereddiecybereddie Posts: 8Questions: 1Answers: 0
edited September 2015 in Free community support

http://postimg.org/image/5yt502oen/

The bellow line works perfectly on my datatables.

{ "aTargets":["Schedule2"], "mData":"Schedules__r.2.Quantity__c", sClass:"Schedule2", "bAutoWidth": true},

My question is how do I add Schedules__r.2.Date__c to this line [like joining strings?].
I have tried to create a function [you can check the included image], But it doesnt work.

Any ideas?

Replies

  • allanallan Posts: 63,732Questions: 1Answers: 10,508 Site admin

    Use columns.render to do this.

    Allan

  • cybereddiecybereddie Posts: 8Questions: 1Answers: 0

    I was reading the documentation ans was thinking that mRender might work too. What do you think? Can you give me an example on how it could work? Appreciated. I have spent already too much time on this trying to figure out the parameters.

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    There is an example of using mRender on the page you have linked to.

  • allanallan Posts: 63,732Questions: 1Answers: 10,508 Site admin

    columns.render is the new name for the legacy mRender option. As tangerine notes there are examples in the documentation. It should be as simple as:

    mRender: function ( data, type, row ) {
      return data +' '+ row.Schedules__r.2.Date__c ;
    }
    

    Allan

  • cybereddiecybereddie Posts: 8Questions: 1Answers: 0
    edited September 2015

    I think its something I am missing on the dot notations.

    This one works.

    { "aTargets":["Schedule1"], "mData":"Schedules__r.1.Quantity__c",
    "mRender": function(data, type, row){
    var data3 = row.Account.Name;
    var data2 = data + " - "+data3;
    return data2;
    }

                    },
    

    This one doesn't!

    { "aTargets":["Schedule1"], "mData":"Schedules__r.1.Quantity__c",
    "mRender": function(data, type, row){
    var data3 = row.Schedules__r.1.Quantity__c;
    var data2 = data + " - "+data3;
    return data2;
    }

                    },
    

    This one doesn't! too

    { "aTargets":["Schedule1"], "mData":"Schedules__r.1.Quantity__c",
    "mRender": function(data, type, row){
    var data3 = row.Schedules__r.1.Date__c;
    var data2 = data + " - "+data3;
    return data2;
    }

                    },
    
  • cybereddiecybereddie Posts: 8Questions: 1Answers: 0

    i found it. This one works.

                    { "aTargets":["Schedule1"], "mData":"Schedules__r.1.Quantity__c", 
                        "mRender": function(data, type, row){                          
                            var data3 = row.Schedules__r[1].Date__c;
                            var data2 = data + " - "+data3;                        
                            return data2;
                        }    
    
                    },
    
  • cybereddiecybereddie Posts: 8Questions: 1Answers: 0

    Thank you guys!!

This discussion has been closed.