same mRender function for multiple columns
same mRender function for multiple columns
jogloran
Posts: 1Questions: 0Answers: 0
I'm using mRender to provide a rendering function for two columns in a DataTable. However, I can't use the same aoColumnDefs entry for both columns, because they access different columns of the data source, and mData only allows me to specify one column index.
Do I really need to repeat the mRender declaration for each column, even when they use the same renderer function, like so?
[code]
$('#vis').dataTable({
'aoColumnDefs': [
{ 'mRender': rendererFunction, 'mData': 3, 'aTargets': [ 3 ] },
{ 'mRender': rendererFunction, 'mData': 4, 'aTargets': [ 4 ] },
]});
[/code]
Do I really need to repeat the mRender declaration for each column, even when they use the same renderer function, like so?
[code]
$('#vis').dataTable({
'aoColumnDefs': [
{ 'mRender': rendererFunction, 'mData': 3, 'aTargets': [ 3 ] },
{ 'mRender': rendererFunction, 'mData': 4, 'aTargets': [ 4 ] },
]});
[/code]
This discussion has been closed.
Replies
[code]
$('#vis').dataTable({
'aoColumnDefs': [
{ 'mRender': rendererFunction, 'aTargets': [ 3, 4 ] },
{ 'mData': 3, 'aTargets': [ 3 ] },
{ 'mData': 4, 'aTargets': [ 4 ] }
]});
[/code]
mData is different so of course that needs to be individually assigned (although in this case, you are just setting it to what DataTables would do anyway - so it shouldn't be needed).
Allan
I'm using mrender function to display, on the id-field, an image containing a link.
In the same table, i have to merge column 5 and 6, and display an image as well.
Below the function I use for the first column.
How do I do that?
Thanks in advance!
[code]
"aoColumnDefs": [ {
"aTargets": [ 0 ],
"mRender": function ( data, type, full ) {
return '';
}
}
],
[/code]
Allan
Testcase is http://www.thevinyltouch.be/dev/index.php?page=Webshop
On the IDfield, there has to be an image (as defined in the code) but how do I specify de mData option?
I'm kinda new with datatables, i'm sorry to bother you with this...
[code]
mData: 0
[/code]
To get the data from the first column.
Allan
i fixed the problem, thanks for the support! datatable is up and running :)
I have an "actions" column where I need to add two links, Edit and Delete.
The links can't be something like edit.php?id=mData and delete.php?id=mData so I have to pass them separately as hidden columns.
How can I use two hidden columns mData (let's say mData: 0, and mData:1, these two being editlink and deletelink) into Actions column?
Also, for the delete link, I need to add a confirmation alert where I have to pass the "title" column value (mData: 2) ... how can I get that?
Thanks for the help!
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [0] }
],
});
});
Here I m Combining Two column into one Column Like userName & His Image.......... Image will be storing in folder............. Path i m Getting from DB .................Works Fine.....
Hasnt mRender deprecated now? How to solve similar problem with the latest version of datatables?
No
fnRender
was removed. ThemRender
option still works, although in the new notation it is calledrender
(i.e.columns.render
).You might find this conversion guide useful.
Allan