custom event for select length
custom event for select length
hi,
i think this is one of the must advanced plugin for jquery it's really good. thank you for it.
i have a question regarding custom event
http://datatables.net/release-datatables/examples/advanced_init/dt_events.html
i see here that 3 events can be bind, where can i get the full list?
my goal is to bind a custom event for pages_table_length changes.
i want to display only rows with .selected class.
thanks.
i think this is one of the must advanced plugin for jquery it's really good. thank you for it.
i have a question regarding custom event
http://datatables.net/release-datatables/examples/advanced_init/dt_events.html
i see here that 3 events can be bind, where can i get the full list?
my goal is to bind a custom event for pages_table_length changes.
i want to display only rows with .selected class.
thanks.
This discussion has been closed.
Replies
Currently there isn't a custom event for length display change - however that's certain a good idea - I'll add it to my list of events to consider for future addition.
Regards,
Allan
can you please advice on a hack for my task?
i see that everything starts at this function:
_fnFeatureHtmlLength
i can add few line to it, is it a good idea (until the next version :))
Allan
i am doing something like this:
[code]
$('#exapmle).dataTable({
"aLengthMenu": [[-1,10,50,100,-2], ["All",10,50,100,"Only Mark"]],
"fnDrawCallback":function(o){
if(o._iDisplayLength == -2){
/* here i think i should call _fnDraw() with sorted array for my rows
i am having trouble to understand where i should do the manipulations
should be something like if($(this).hassClass('selected')) o.tbody.push(this);
}
*/
}
});
[/code]
this is the modified function code.
now when it's done i think i made a mistake hacking your code like this (sorry)
i should have play with adding bind option and not mess this function.
maybe if i will have more time in the future (i only had a couple of hours to play with it.)
initialization:
[code]
$('#exapmle).dataTable({
"aLengthMenu": [[-1,10,50,100,-2], ["All",10,50,100,"Only Mark"]]
})
[/code]
core code:
[code]
function _fnDraw( oSettings )
{
var i, iLen, n;
var anRows = [];
var iRowCount = 0;
var iStripes = oSettings.asStripeClasses.length;
var iOpenRows = oSettings.aoOpenRows.length;
/* Provide a pre-callback function which can be used to cancel the draw is false is returned */
var aPreDraw = _fnCallbackFire( oSettings, 'aoPreDrawCallback', 'preDraw', [oSettings] );
if ( $.inArray( false, aPreDraw ) !== -1 )
{
_fnProcessingDisplay( oSettings, false );
return;
}
oSettings.bDrawing = true;
/* Check and see if we have an initial draw position from state saving */
if ( oSettings.iInitDisplayStart !== undefined && oSettings.iInitDisplayStart != -1 )
{
if ( oSettings.oFeatures.bServerSide )
{
oSettings._iDisplayStart = oSettings.iInitDisplayStart;
}
else
{
oSettings._iDisplayStart = (oSettings.iInitDisplayStart >= oSettings.fnRecordsDisplay()) ?
0 : oSettings.iInitDisplayStart;
}
oSettings.iInitDisplayStart = -1;
_fnCalculateEnd( oSettings );
}
/* Server-side processing draw intercept */
if ( oSettings.bDeferLoading )
{
oSettings.bDeferLoading = false;
oSettings.iDraw++;
}
else if ( !oSettings.oFeatures.bServerSide )
{
oSettings.iDraw++;
}
else if ( !oSettings.bDestroying && !_fnAjaxUpdate( oSettings ) )
{
return;
}
if ( oSettings.aiDisplay.length !== 0 )
{
var iStart = oSettings._iDisplayStart;
var iEnd = oSettings._iDisplayEnd;
//Added by Elad for custom event
var bMakeCustomBody = false;
if(iEnd == -2)
{
bMakeCustomBody = true;
iEnd = oSettings.aoData.length; //we want to go thru all the TR's
}
//End Elad
if ( oSettings.oFeatures.bServerSide )
{
iStart = 0;
iEnd = oSettings.aoData.length;
}
for ( var j=iStart ; j