Hi, I write code for data table and pagination feature, it is working for a particular page. Now I want to make this code for common to multiple page.
But not able to do. plz suggest me the require change in my code. my code is as follow:
<script type="text/javascript" charset="utf-8">
$.fn.dataTableExt.oPagination.iTweenTime = 100;
$.fn.dataTableExt.oPagination.scrolling = {
"fnInit": function ( oSettings, fnCallbackDraw )
{
var nPaging = oSettings.anFeatures.p;
oSettings.nPrevious = document.createElement( 'div' );
oSettings.nNext = document.createElement( 'div' );
if ( oSettings.sTableId !== '' )
{
nPaging.setAttribute( 'id', oSettings.sTableId+'_paginate' );
oSettings.nPrevious.setAttribute( 'id', oSettings.sTableId+'_previous' );
oSettings.nNext.setAttribute( 'id', oSettings.sTableId+'_next' );
}
oSettings.nPrevious.className = "paginate_disabled_previous";
oSettings.nNext.className = "paginate_disabled_next";
oSettings.nPrevious.title = oSettings.oLanguage.oPaginate.sPrevious;
oSettings.nNext.title = oSettings.oLanguage.oPaginate.sNext;
nPaging.appendChild( oSettings.nPrevious );
nPaging.appendChild( oSettings.nNext );
$(nPaging).insertAfter( oSettings.nTable );
$(oSettings.nPrevious).click( function() {
if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
{
return;
}
oSettings.iPagingLoopStart = oSettings._iDisplayStart;
oSettings.iPagingEnd = oSettings._iDisplayStart - oSettings._iDisplayLength;
if ( oSettings.iPagingEnd < 0 )
{
oSettings.iPagingEnd = 0;
}
var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
var innerLoop = function () {
if ( oSettings.iPagingLoopStart > oSettings.iPagingEnd ) {
oSettings.iPagingLoopStart--;
oSettings._iDisplayStart = oSettings.iPagingLoopStart;
fnCallbackDraw( oSettings );
setTimeout( function() { innerLoop(); }, iTween );
} else {
oSettings.iPagingLoopStart = -1;
}
};
innerLoop();
} );
$(oSettings.nNext).click( function() {
if ( typeof oSettings.iPagingLoopStart != 'undefined' && oSettings.iPagingLoopStart != -1 )
{
return;
}
oSettings.iPagingLoopStart = oSettings._iDisplayStart;
if ( oSettings._iDisplayStart + oSettings._iDisplayLength < oSettings.fnRecordsDisplay() )
{
oSettings.iPagingEnd = oSettings._iDisplayStart + oSettings._iDisplayLength;
}
var iTween = $.fn.dataTableExt.oPagination.iTweenTime;
var innerLoop = function () {
if ( oSettings.iPagingLoopStart < oSettings.iPagingEnd ) {
oSettings.iPagingLoopStart++;
oSettings._iDisplayStart = oSettings.iPagingLoopStart;
fnCallbackDraw( oSettings );
setTimeout( function() { innerLoop(); }, iTween );
} else {
oSettings.iPagingLoopStart = -1;
}
};
innerLoop();
} );
$(oSettings.nPrevious).bind( 'selectstart', function () { return false; } );
$(oSettings.nNext).bind( 'selectstart', function () { return false; } );
},
"fnUpdate": function ( oSettings, fnCallbackDraw )
{
if ( !oSettings.anFeatures.p )
{
return;
}
oSettings.nPrevious.className =
( oSettings._iDisplayStart === 0 ) ?
"paginate_disabled_previous" : "paginate_enabled_previous";
oSettings.nNext.className =
( oSettings.fnDisplayEnd() == oSettings.fnRecordsDisplay() ) ?
"paginate_disabled_next" : "paginate_enabled_next";
}
}
jQuery.fn.dataTableExt.aTypes.push(
function ( sData )
{
var sValidChars = "0123456789-,";
var Char;
var bDecimal = false;
for ( i=0 ; i<sData.length ; i++ )
{
Char = sData.charAt(i);
if (sValidChars.indexOf(Char) == -1)
{
return null;
}
if ( Char == "," )
{
if ( bDecimal )
{
return null;
}
bDecimal = true;
}
}
return 'numeric-comma';
}
);
jQuery.fn.dataTableExt.oSort['numeric-comma-asc'] = function(a,b) {
var x = (a == "-") ? 0 : a.replace( /,/, "." );
var y = (b == "-") ? 0 : b.replace( /,/, "." );
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['numeric-comma-desc'] = function(a,b) {
var x = (a == "-") ? 0 : a.replace( /,/, "." );
var y = (b == "-") ? 0 : b.replace( /,/, "." );
x = parseFloat( x );
y = parseFloat( y );
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
$(document).ready(function() {
$('#preactivitymanagementtable').dataTable( {
"sPaginationType": "scrolling",
"bAutoWidth": false,
} );
} );
</script>