Have a plugin use a Plugin function
Have a plugin use a Plugin function
talkitivewizard
Posts: 30Questions: 0Answers: 0
How would you go about doing this. I have found that I am in need of combineing... or rather modifying... the fnReloadAjax plugin to use the fnStandingRedraw function as opposed to just regular redraw. Now I've gotten it to work by pasting the code from the StandingRedraw to ReloadAjax... but that's a very... hackish way to do things. Any suggestions? Works Beautifully btw...
[code]
jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback )
{
console.log("here");
if ( typeof sNewSource != 'undefined' )
{
oSettings.sAjaxSource = sNewSource;
}
console.log(oSettings.sAjaxSource);
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
oSettings.fnServerData( oSettings.sAjaxSource, null, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
for ( var i=0 ; i
[code]
jQuery.fn.dataTableExt.oApi.fnReloadAjax = function ( oSettings, sNewSource, fnCallback )
{
console.log("here");
if ( typeof sNewSource != 'undefined' )
{
oSettings.sAjaxSource = sNewSource;
}
console.log(oSettings.sAjaxSource);
this.oApi._fnProcessingDisplay( oSettings, true );
var that = this;
oSettings.fnServerData( oSettings.sAjaxSource, null, function(json) {
/* Clear the old information from the table */
that.oApi._fnClearTable( oSettings );
/* Got the data - add it to the table */
for ( var i=0 ; i
This discussion has been closed.
Replies
I hadn't really considered doing a standing redraw with reload Ajax before, since it tends to be entirely new data, and thus one would want to start from the start. But perhaps you are using data which is just being updated, or some other place where this makes since. In which case, just setting _iDisplayStart before the draw will do nicely. The thing is that you will want DataTables to redo the filtering and sorting, and those functions automatically call the draw. So yes, this isn't perfect, in that there is a 'spare' draw in there (I'll have a think about how that might be avoided), but in practical terms, it should happen so fast that no one will see it...
Allan
It has been my experiance though, that DataTables handles really well, even under a few thousand records...
And anything beats doing it the way we were doing it before (aka full page refreshes *hides in shame*).
However, that didn't really answer my question I don't think...
Is there a way to call a plugin function from a plugin?" Like make a plugin that has a dependency on another plugin? I haven't gotten into building plugins for this yet. I plan on actually trying to though, as I feel that this project is a wonderful thing and the love and joy it brings should be spread to the world :D
[code]
$.fn.dataTableExt.oApi.fn1 = function ( settings, a ) {
console.log( o, a );
this.fn2( 2 );
};
$.fn.dataTableExt.oApi.fn2 = function ( settings, a ) {
console.log( o, a );
};
$(document).ready(function() {
var o = $('#example').dataTable();
o.fn1(1);
} );
[/code]
Note that DataTables adds the settings object for the 'inner' API call as well.
Allan