get column def in mRender

get column def in mRender

selbadryselbadry Posts: 1Questions: 1Answers: 0
edited May 2014 in DataTables

Hi all,

First I would like to thank you for this awesome datatable :)

I was hoping you guys could help me with my problem

My datatable columns are saved in my database, when I construct my datatables I load all my columns from my database and prepare my aoColumnDefs accordingly. Here is part of my code to clarify what I mean:

var allColumnsArray = [];

// colData is an array with all my column properties retrieved from the database
for (var i in colData) {

            var col = {};
            col['mData'] = colData[i].ColumnName;
            col['aTargets'] = [colData[i].ColumnOrder - 1];
            col['mRender'] = function (data, type, full) {


                        // My problem is here
                      if( colData[i].TemplateFunction!="")
                      {
                            // do custom code here according to value of colData[i].TemplateFunction
                       }

                    }

allColumnsArray.push(col);
}

Then when constructing my datatable I just specify that

"aoColumnDefs": allColumns

I want to add an mRender to each column definition, but each mRender is supposed to be customized according to the value of TemplateFunction column which is retrieved from the db

How can I access my colData from within mRender?

I hope I was able to explain my problem

This discussion has been closed.