Hi. I just want to ask some question about 'mRender'.
For some fields I specify it as a function to return some formatted content. Something like this
So I made a conclusion that during rendering of a table the 'mRender' function is called 3 times for each record.
My simple question is. Is that an optimal way of doing it? mRender (as I understand) gives us a final content to be placed into <td>. Why we should call it three times?
Sorry, I did not dig deep into the code of the dataDables. Maybe it is a right way of doing it. Maybe it does not matter much. Anyway, I do not have a lot of records to be this an performance issue for me. I just asking. Also here is my whole cnfig
Hmm. When setting "bFilter": false, it is only 2 times for each record.
For some fields I specify it as a function to return some formatted content. Something like this
"aoColumns": [ { "mData": "createdDate", "mRender": function ( data, type, full ) { console.log("i_"+full.id); var curDate = new Date(data); if (curDate.toDateString() == new Date().toDateString()) { return curDate.getHours()+':'+curDate.getMinutes(); } else { var day = d_names[curDate.getDay()]; return '<abbr title="'+day+'">'+day[0]+'</abbr> +curDate.getHours()+':'+curDate.getMinutes(); } } },So, when I have, for example 2 records(actually I have 8 records :-)) with ids 42 and 25, I see during table rendering in my firebug console output like this:
i_42 i_42 i_25 i_25 i_42 i_25
So I made a conclusion that during rendering of a table the 'mRender' function is called 3 times for each record.
My simple question is. Is that an optimal way of doing it? mRender (as I understand) gives us a final content to be placed into <td>. Why we should call it three times?
Sorry, I did not dig deep into the code of the dataDables. Maybe it is a right way of doing it. Maybe it does not matter much. Anyway, I do not have a lot of records to be this an performance issue for me. I just asking. Also here is my whole cnfig
var table = this.$el.dataTable( { "sDom": "<'row-fluid'<'span6'l><'span6 jqtReload'>r>t<'row-fluid'<'span6'i><'span6'>>", "bPaginate": true, "bFilter": true, "bSort": false, "bInfo": true, "bAutoWidth": false, "bProcessing": true, "sScrollY": "185px", "bScrollCollapse": true, sAjaxSource: "", sAjaxDataProp: "", fnServerData: function( sSource, aoData, fnCallback ){ fnCallback(_that.collection.toJSON()); }, "aLengthMenu": [[3, 5, 8, 10, -1], [3, 5, 8, 10, "All"]], iDisplayLength: -1, "aoColumns": [ { "mData": "createdDate", "mRender": function ( data, type, full ) { console.log("i_"+full.id); var curDate = new Date(data); if (curDate.toDateString() == new Date().toDateString()) { return curDate.getHours()+':'+curDate.getMinutes(); } else { var day = d_names[curDate.getDay()]; return '<abbr title="'+day+'">'+day[0]+'</abbr> '+curDate.getHours()+':'+curDate.getMinutes(); } } }, { "mData": null, "mRender": function ( data, type, full ) { if (full.toAddress === undefined) { return full.fromAddress; } else { return full.fromAddress + ' <i class="icon-arrow-right"></i> ' + full.toAddress; } } }, { "mData": "creator" }, { "mData": "region" }, { "mData": "state" }, { "mData": "statusId", "mRender": function ( data, type, full ) { return '<i class="icon-ok-sign"></i>'; } } ] } );
Hmm. When setting "bFilter": false, it is only 2 times for each record.