columns.render does not allow to reference the column of data
columns.render does not allow to reference the column of data
fbi1970
Posts: 1Questions: 0Answers: 0
at doc page: http://next.datatables.net/reference/option/columns.render
is stated the proto of: function render( data, type, row )
data contains data of cell, type is 'display'/'filter'/etc. and row is reference to full row data, but it's not possible to get the column where data is.
I think you should add an argument with column index or column reference.
Thanks in advance
is stated the proto of: function render( data, type, row )
data contains data of cell, type is 'display'/'filter'/etc. and row is reference to full row data, but it's not possible to get the column where data is.
I think you should add an argument with column index or column reference.
Thanks in advance
This discussion has been closed.
Replies
If you want a dynamic function that can be used for multiple columns, then a simple closure that returns a function could be used.
Thanks,
Allan
[code]
var renders = {};
renders.base = function(data, type, full, name) { /* ... */ }
$.each(['col1','col2'], function( i, v ) {
renders[v] = function(d,t,f){ return renders.base(d,t,f,v) }
});
// columns for datatable init:
[
{ data: "col1", render: renders.col1 },
{ data: "col2", render: renders.col2 }
]
[/code]
Hope it helps
[code]
function render ( i ) {
return function ( data, type, full ) {
return 'whatever :-)';
};
}
// columns
[
{ data: "col1", render: render( 1 ) },
{ data: "col2", render: render( 2 ) }
]
[/code]
Allan