Returning a jQuery element from mRender 'display' mode?
Returning a jQuery element from mRender 'display' mode?
benallfree
Posts: 7Questions: 0Answers: 0
Hi, I love the mRender feature.
It seems that it would be convenient if a jQuery element could be returned. That way you can dynamically create an element and load it with click() handlers and data().
I don't know if this is the right place to discuss mods, but perhaps I can get some feedback on this change. I'd fork the project and submit a pull request, but I don't fully understand the packaging system. The main zip download is different from cloning the repo.
Was:
[code]
nTd.innerHTML = (typeof oCol.fnRender === 'function' && (!oCol.bUseRendered || oCol.mData === null)) ?
_fnRender( oSettings, iRow, i ) :
_fnGetCellData( oSettings, iRow, i, 'display' );
[/code]
Changed to:
[code]
var display_obj = (typeof oCol.fnRender === 'function' && (!oCol.bUseRendered || oCol.mData === null)) ?
_fnRender( oSettings, iRow, i ) :
_fnGetCellData( oSettings, iRow, i, 'display' );
if(typeof(display_obj)=="object")
{
$(nTd).append(display_obj);
} else {
nTd.innerHTML = display_obj;
}
[/code]
It seems that it would be convenient if a jQuery element could be returned. That way you can dynamically create an element and load it with click() handlers and data().
I don't know if this is the right place to discuss mods, but perhaps I can get some feedback on this change. I'd fork the project and submit a pull request, but I don't fully understand the packaging system. The main zip download is different from cloning the repo.
Was:
[code]
nTd.innerHTML = (typeof oCol.fnRender === 'function' && (!oCol.bUseRendered || oCol.mData === null)) ?
_fnRender( oSettings, iRow, i ) :
_fnGetCellData( oSettings, iRow, i, 'display' );
[/code]
Changed to:
[code]
var display_obj = (typeof oCol.fnRender === 'function' && (!oCol.bUseRendered || oCol.mData === null)) ?
_fnRender( oSettings, iRow, i ) :
_fnGetCellData( oSettings, iRow, i, 'display' );
if(typeof(display_obj)=="object")
{
$(nTd).append(display_obj);
} else {
nTd.innerHTML = display_obj;
}
[/code]
This discussion has been closed.
Replies
The fnCreatedCell and fnCreatedRow callbacks are designed for this kind of thing, and also take into account deferred rendering etc. When those methods are called, you know that the cell is ready for events.
However, this is something that could use further refinement, so further thoughts are very welcome on this.
Regards,
Allan
-Ben
Yes - exactly that. fnCreatedCell is column based, while fnCreatedRow is a 'top level' callback.
Allan