⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Auto Refresh Using DataTables theme



gunjannigam

gunjannigam
  • profile picture
  • Member

Posted 10 May 2013 - 12:07 PM

Hi,

I am trying to use grocery crud and data tables theme. I want my data table to auto refresh after a given a time interval. For this I have been using http://datatables.net/plug-ins/api#fnStandingRedraw along with java-script setInterval. This used to work when I had used data tables earlier without grocery crud. But with grocery crud how can I get this code working or what else could I do to auto refresh my data tables after a set interval

 

 

$.fn.dataTableExt.oApi.fnStandingRedraw = function(oSettings) {
    //redraw to account for filtering and sorting
    // concept here is that (for client side) there is a row got inserted at the end (for an add) 
    // or when a record was modified it could be in the middle of the table
    // that is probably not supposed to be there - due to filtering / sorting
    // so we need to re process filtering and sorting
    // BUT - if it is server side - then this should be handled by the server - so skip this step
    if(oSettings.oFeatures.bServerSide === false){
        var before = oSettings._iDisplayStart;
        oSettings.oApi._fnReDraw(oSettings);
        //iDisplayStart has been reset to zero - so lets change it back
        oSettings._iDisplayStart = before;
        oSettings.oApi._fnCalculateEnd(oSettings);
    }
    
    //draw the 'current' page
    oSettings.oApi._fnDraw(oSettings);
};
var auto_refresh = setInterval(
function ()
{
var oTable = $('#groceryCrudTable').dataTable();
/* Re-draw the table - you wouldn't want to do it here, but it's an example :-) */
oTable.fnStandingRedraw();
}, 60000);

 


davidoster

davidoster
  • profile picture
  • Member

Posted 12 May 2013 - 06:21 AM

The code that controls the datatable's js is under assets\grocery_crud\themes\datatables\js

The file datatables.js is the one responsible for the operations of the datatables appearence.


gunjannigam

gunjannigam
  • profile picture
  • Member

Posted 13 May 2013 - 06:35 AM

The code that controls the datatable's js is under assets\grocery_crud\themes\datatables\js

The file datatables.js is the one responsible for the operations of the datatables appearence.

Yes I wrote the above code in the above mention datatable.js file only but still its not working. Just wanted to clarify the above codes uses ajax call. Does the grocery crud api support all ajax functionality of original datatables 


davidoster

davidoster
  • profile picture
  • Member

Posted 13 May 2013 - 10:28 AM

I think it doesn't.

I think only flexigrid theme uses ajax calls.


victor

victor
  • profile picture
  • Member

Posted 13 May 2013 - 14:29 PM

you can create own js to update grid. but you should make own php function for that too. this my thinking about your problem. But in this case I wouldn't use GC, because it will take less time that GC will take.